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.gz
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');
an> * - Update to version 0.6.1krion2004-03-252-5/+3 * Add arpscan-0.2,krion2004-03-235-0/+55 * Drop maintainership.clement2004-03-222-2/+2 * - Update to 0.8.5pav2004-03-223-45/+84 * Add size data, approved by maintainers.trevor2004-03-212-0/+2 * - Utilize PLIST_FILESkrion2004-03-214-11/+7 * - Utilize PLIST_FILESkrion2004-03-218-22/+16 * SIZEifyerwin2004-03-201-0/+1 * Remove empty file.kuriyama2004-03-203-0/+0 * - Move arpwatch-devel to new category - net-mgmtkrion2004-03-202-1/+2 * - SIZE'ifykrion2004-03-201-0/+1 * SIZEifymarcus2004-03-193-0/+3 * Add size data, approved by maintainers.trevor2004-03-194-0/+4 * Add size data, approved by maintainers.trevor2004-03-194-0/+4 * Restore Emil Mikulik as maintainer. He sent me his new e-mailtrevor2004-03-191-1/+1 * Add SIZEarved2004-03-181-0/+1 * - SIZEify.mich2004-03-183-0/+3 * Add SIZE data.perky2004-03-181-0/+1 * SIZEifymr2004-03-181-0/+1 * Use the maintainer's new e-mail address.trevor2004-03-183-3/+3 * E-mail to the maintainer bounced:trevor2004-03-181-1/+1 * Add size data.trevor2004-03-182-0/+2 * Add size data.trevor2004-03-183-0/+4 * SIZEify.kuriyama2004-03-184-0/+4 * SIZEify.trevor2004-03-182-0/+2 * Correct MASTER_SITE_SUBDIR.demon2004-03-151-1/+1 * - Update to 1.27pav2004-03-155-6/+6 * - Fix nagios dependencypav2004-03-151-2/+1 * - Update to 1.9007krion2004-03-153-8/+13 * - Update to 9.3.1pav2004-03-145-10/+15 * o Bump $LIB_DEPENDS line to chase expat's shlib version.kuriyama2004-03-141-2/+2 * Whoa there, boy, that's a mighty big commit y'all have there...ade2004-03-1411-11/+11 * BROKEN on 5.x: Does not compilekris2004-03-141-1/+7 * - Fix dependencieskrion2004-03-122-5/+5 * - Fix incorrect accept(2) usagekrion2004-03-124-7/+14 * o More $REINPLACE_CMD'ify.kuriyama2004-03-123-15/+15 * Remove USE_SIZE now that it's used by default.olgeni2004-03-121-1/+0 * Reset maintainership. Maintainer does not have the time toerwin2004-03-121-1/+1 * o Fix on 4.x.kuriyama2004-03-113-18/+6 * Mark broken for 4.x for the time being.kuriyama2004-03-113-0/+12 * Various fixes / improvements.kuriyama2004-03-1057-738/+2151 * Unbreak: chase checksum change on PDF file (documentation update).olgeni2004-03-072-2/+10 * - Update to version 1.4krion2004-03-063-7/+11 * - Add more MASTER_SITESkrion2004-03-041-1/+2 * - Fix MASTER_SITESkrion2004-03-011-1/+2 * - Update to version 0.16krion2004-02-292-3/+3 * Avoid "kvm_read: Bad address" error.kuriyama2004-02-296-3/+33 * fix PKGORIGIN for net/zabbix-agenteik2004-02-292-2/+2 * Fix build on CURRENTarved2004-02-291-3/+7 * USE_MYSQLarved2004-02-291-5/+7 * [maintainer] zabbix: version bump 1.0b13 -> 1.0b14edwin2004-02-298-88/+18 * Let the port choose between a PGSQL or MYSQL backend.edwin2004-02-294-10/+134 * Update to 0.47edwin2004-02-283-4/+4 * - Obey PTHREAD_LIBS also when libpthread exists.netchild2004-02-273-45/+74 * - Mark this port as DEPRECATED (removal is scheduled on 2004-05-26)clement2004-02-271-0/+3 * fix PKGORIGINeik2004-02-251-1/+0 * - Update to 0.7.6pav2004-02-253-6/+61 * - Update to 1.26eik2004-02-2422-223/+461 * Say hello to the new "net-mgmt" category. There are probably morewollman2004-02-23