aboutsummaryrefslogtreecommitdiffstats
path: root/libversit/vobject.c
diff options
context:
space:
mode:
authorVadim Strizhevsky <vadim@src.gnome.org>2000-01-01 04:35:35 +0800
committerVadim Strizhevsky <vadim@src.gnome.org>2000-01-01 04:35:35 +0800
commit01f62452292ef0806edd03eced94e2637c146651 (patch)
treedf0bd838667c0d8c2131dec0bb75405207e5e218 /libversit/vobject.c
parenteb7c5ae3c5fa9ab3bab2a60d7a0c8a5a4ed93cb7 (diff)
downloadgsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar.gz
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar.bz2
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar.lz
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar.xz
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.tar.zst
gsoc2013-evolution-01f62452292ef0806edd03eced94e2637c146651.zip
Fix handling of QUOTED-PRINTABLE strings. writeQPString has been fixed to
* libversit/vobject.c: Fix handling of QUOTED-PRINTABLE strings. writeQPString has been fixed to escape all chars according to rfc 1521. writeString has been added for writing regular non-quoted strings. * gmomecard/card.c: Fix infinite file growth problems, by not adding the same attribute to the vcard property more than once. * gnomecard/address-conduit.[ch]: Remove custom \n escaping and always use QUOTED-PRINTABLE when necessary because libversit has been fixed appropriately. Also remove various compiler warnings. svn path=/trunk/; revision=1527
Diffstat (limited to 'libversit/vobject.c')
-rw-r--r--libversit/vobject.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/libversit/vobject.c b/libversit/vobject.c
index cd223dcce8..d685b04278 100644
--- a/libversit/vobject.c
+++ b/libversit/vobject.c
@@ -1149,34 +1149,55 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
return 1;
}
+static void writeString(OFile *fp, const char *s)
+{
+ appendsOFile(fp,s);
+}
+
static void writeQPString(OFile *fp, const char *s)
{
+ char buf[4];
+ int count=0;
const char *p = s;
+
while (*p) {
- if (*p == '\n') {
- if (p[1]) appendsOFile(fp,"=0A=");
- }
- appendcOFile(fp,*p);
- p++;
+ /* break up lines biggger than 75 chars */
+ if(count >=74){
+ count=0;
+ appendsOFile(fp,"=\n");
+ }
+
+ /* escape any non ASCII characters and '=' as per rfc1521 */
+ if (*p<= 0x1f || *p >=0x7f || *p == '=' ) {
+ sprintf(buf,"=%02X",(unsigned char)*p);
+ appendsOFile(fp,buf);
+ count+=3;
+ } else {
+ appendcOFile(fp,*p);
+ count++;
}
+ p++;
+ }
}
static void writeVObject_(OFile *fp, VObject *o);
-static void writeValue(OFile *fp, VObject *o, unsigned long size)
+static void writeValue(OFile *fp, VObject *o, unsigned long size,int quote)
{
if (o == 0) return;
switch (VALUE_TYPE(o)) {
case VCVT_USTRINGZ: {
char *s = fakeCString(USTRINGZ_VALUE_OF(o));
- writeQPString(fp, s);
+ if(quote) writeQPString(fp, s);
+ else writeString(fp,s);
deleteStr(s);
break;
}
case VCVT_STRINGZ: {
- writeQPString(fp, STRINGZ_VALUE_OF(o));
+ if(quote) writeQPString(fp, STRINGZ_VALUE_OF(o));
+ else writeString(fp,STRINGZ_VALUE_OF(o));
break;
}
case VCVT_UINT: {
@@ -1216,7 +1237,7 @@ static void writeAttrValue(OFile *fp, VObject *o)
appendcOFile(fp,';');
if (VALUE_TYPE(o)) {
appendcOFile(fp,'=');
- writeValue(fp,o,0);
+ writeValue(fp,o,0,0);
}
}
@@ -1246,6 +1267,7 @@ static int inList(const char **list, const char *s)
static void writeProp(OFile *fp, VObject *o)
{
+ int isQuoted=0;
if (NAME_OF(o)) {
struct PreDefProp *pi;
VObjectIterator t;
@@ -1267,6 +1289,8 @@ static void writeProp(OFile *fp, VObject *o)
s = NAME_OF(eachProp);
if (stricmp(VCGroupingProp,s) && !inList(fields_,s))
writeAttrValue(fp,eachProp);
+ if (stricmp(VCQPProp,s)==0 || stricmp(VCQuotedPrintableProp,s)==0)
+ isQuoted=1;
}
if (fields_) {
int i = 0, n = 0;
@@ -1281,7 +1305,7 @@ static void writeProp(OFile *fp, VObject *o)
}
fields = fields_;
for (i=0;i<n;i++) {
- writeValue(fp,isAPropertyOf(o,*fields),0);
+ writeValue(fp,isAPropertyOf(o,*fields),0,isQuoted);
fields++;
if (i<(n-1)) appendcOFile(fp,';');
}
@@ -1293,7 +1317,7 @@ static void writeProp(OFile *fp, VObject *o)
VObject *p = isAPropertyOf(o,VCDataSizeProp);
if (p) size = LONG_VALUE_OF(p);
appendcOFile(fp,':');
- writeValue(fp,o,size);
+ writeValue(fp,o,size,isQuoted);
}
appendcOFile(fp,'\n');