summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-10-06 15:23:42 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2016-10-06 16:40:43 +0200
commit7c9a4bf12a574c65a09689527e61b1fc72f35c0b (patch)
treec2dfea7f24e9e2b86ab2bcb92e25531e695b20d7
parent59b55aa5cf2be44a93cbce77e153c4cd250f76f2 (diff)
mimedirprofile.cpp: support broken quoted-printable from Nokia N9 (FDO #98019)libsynthesis_3.4.0.47+syncevolution-1-5-2
The Nokia N9 vCalendar implementation sends ==0A=0D= at the end of the line when it should send just the =. Apparently the CRLF octets get inserted before quoted-printable encoding and then get encoded. Without working around that in our parser, we end up inserting extra characters. Tested and improved by deloptes@gmail.com. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
-rw-r--r--src/sysync/mimedirprofile.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sysync/mimedirprofile.cpp b/src/sysync/mimedirprofile.cpp
index 84f0271..56ba769 100644
--- a/src/sysync/mimedirprofile.cpp
+++ b/src/sysync/mimedirprofile.cpp
@@ -1937,6 +1937,26 @@ static void decodeValue(
uInt16 code;
const char *s;
char hex[2];
+
+ // The Nokia N9 vCalendar implementation sends ==0A=0D= at the end of
+ // the line when it should send just the =. Apparently the CRLF octets
+ // get inserted before quoted-printable encoding and then get encoded.
+ // Such a sequence is invalid because = cannot be used literally
+ // and must be followed by characters representing the hex value,
+ // i.e. == is already invalid.
+ //
+ // We must skip over the entire sequence and then move forward to the
+ // next valid character, i.e. skip over the soft line break that
+ // follows the ==0A=0D.
+ //
+ // Without this special case, the code below would insert additional
+ // characters into the decoded text.
+ if (!strcmp(p, "==0A=0D=")) {
+ p += strlen("==0A=0D=") - 1;
+ p=nextunfolded(p,aMimeMode,true);
+ continue;
+ }
+
s=nextunfolded(p,aMimeMode,true);
if (*s==0) break; // end of string
hex[0]=*s; // first digit