XML parsing bughfix.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20221 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-10-13 16:46:09 +00:00
parent 27d31a0156
commit 1edd85f95f
3 changed files with 15 additions and 3 deletions

View file

@ -4034,9 +4034,10 @@ static BOOL warned = NO; if (warned == NO) { warned = YES; NSLog(@"WARNING, use
- (NSString*) stringByEscapingXML
{
unsigned length = [self length];
unsigned output = length;
unsigned output = 0;
unichar *from;
unsigned i = 0;
BOOL escape = NO;
from = NSZoneMalloc (NSDefaultMallocZone(), sizeof(unichar) * length);
[self getCharacters: from];
@ -4052,15 +4053,18 @@ static BOOL warned = NO; if (warned == NO) { warned = YES; NSLog(@"WARNING, use
case '"':
case '\'':
output += 6;
escape = YES;
break;
case '&':
output += 5;
escape = YES;
break;
case '<':
case '>':
output += 4;
escape = YES;
break;
default:
@ -4075,13 +4079,15 @@ static BOOL warned = NO; if (warned == NO) { warned = YES; NSLog(@"WARNING, use
output++;
c /= 10;
}
escape = YES;
}
output++;
break;
}
}
}
if (output > length)
if (escape == YES)
{
unichar *to;
unsigned j = 0;