Fix error folding header with non-ascci data

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39413 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-02-25 11:47:49 +00:00
parent a51249a65d
commit 297495896d

View file

@ -3911,14 +3911,14 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
NSString *str, BOOL *ok)
{
NSUInteger pos = 0;
NSUInteger size = [str length];
BOOL hadEncodedWord = NO;
*ok = YES;
if (YES == oldStyleFolding)
{
BOOL needSpace = NO;
NSUInteger size = [str length];
BOOL needSpace = NO;
while (pos < size)
{
@ -4048,13 +4048,13 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
*/
[m appendBytes: ptr + pos length: next - pos];
offset += next - pos;
pos = next;
pos += next;
if (pos < len)
{
/* We have more text to output, so fold the line.
*/
[m appendBytes: "\r\n" length: 2];
[m appendBytes: ptr + pos length:1 ];
[m appendBytes: ptr + pos length: 1];
pos++;
offset = 1;
}
@ -4110,7 +4110,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
offset = 1;
}
charLength = quotableLength(ptr + pos, size - pos,
charLength = quotableLength(ptr + pos, len - pos,
fold - offset - overhead, &quotedLength);
if (quotedLength > (charLength * 4) / 3)
{