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:
CaS 2004-10-13 16:46:09 +00:00
parent 8d263f4559
commit 95daaf5f4c
3 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,7 @@
2004-10-13 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSXML.m: Fix bug escaping XML special chartacters.
2004-10-11 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/defaults.m: fix for domains and default names contaning

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;

View file

@ -1976,6 +1976,7 @@ main(int argc, char **argv, char **env)
{
if (hDate == nil || [gDate earlierDate: hDate] == hDate)
{
NSData *d;
GSXMLNode *root;
GSXMLParser *parser;
AGSIndex *localRefs;
@ -2016,7 +2017,8 @@ main(int argc, char **argv, char **env)
[html setLocalRefs: localRefs];
[html setInstanceVariablesAtEnd: instanceVarsAtEnd];
generated = [html outputDocument: root];
if ([generated writeToFile: htmlfile atomically: YES] == NO)
d = [generated dataUsingEncoding: NSUTF8StringEncoding];
if ([d writeToFile: htmlfile atomically: YES] == NO)
{
NSLog(@"Sorry unable to write %@", htmlfile);
}