Aim to improve compatibility with old/buggy parsers.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2016-02-18 15:52:00 +00:00
parent 953ba0a549
commit b1c6a91faf
2 changed files with 16 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2016-02-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSMime.m:
Fold using tabs between key=value tokens in structured headers
in the hope that it will improve compatibility with code which
doesn't cope well with a space as the folding character.
2016-02-15 Richard Frith-Macdonald <rfm@gnu.org> 2016-02-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileManager.m: Use NSDebugLog for most debug warnings * Source/NSFileManager.m: Use NSDebugLog for most debug warnings

View file

@ -3845,7 +3845,7 @@ appendBytes(NSMutableData *m, NSUInteger offset, NSUInteger fold,
uint8_t wsp; uint8_t wsp;
uint8_t buf[3]; uint8_t buf[3];
/* Modern folding preserved exact whitespace characters. /* Modern folding preserves exact whitespace characters.
*/ */
if (size > 0 && isWSP(bytes[0])) if (size > 0 && isWSP(bytes[0]))
{ {
@ -4289,10 +4289,13 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
/* Crude heuristic ... /* Crude heuristic ...
* if the length of the key=value will definitely be * if the length of the key=value will definitely be
* too long to fit on a line, fold right now. * too long to fit on a line, fold right now.
* Since we are producing a key=value pair in a structured
* field, we use a tab to fold to maximise the chances of a
* parser understanding it.
*/ */
if (fold > 0 && offset + kLength + vLength + 1 >= fold) if (fold > 0 && offset + kLength + vLength + 1 >= fold)
{ {
[md appendBytes: "\r\n " length: 3]; [md appendBytes: "\r\n\t" length: 3];
offset = 1; offset = 1;
} }
else else
@ -4310,10 +4313,13 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
/* Crude heuristic ... if the length of the value will definitely be /* Crude heuristic ... if the length of the value will definitely be
* too long to fit on a line, fold right now. * too long to fit on a line, fold right now.
* Since we are producing a key=value pair in a structured
* field, we use a tab to fold to maximise the chances of a
* parser understanding it.
*/ */
if (fold > 0 && offset + vLength > fold) if (fold > 0 && offset + vLength > fold)
{ {
[md appendBytes: "\r\n " length: 3]; [md appendBytes: "\r\n\t" length: 3];
offset = 1; offset = 1;
} }
offset = appendString(md, offset, fold, v, &ok); offset = appendString(md, offset, fold, v, &ok);