Fix problem with property list escape sequences.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17446 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-08-07 07:17:03 +00:00
parent 144e22edcc
commit 090b0a10f2
3 changed files with 23 additions and 59 deletions

View file

@ -1,3 +1,10 @@
2003-08-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSString.m: nodeToObject() fix error in handling escape
sequences in strings ... only treat a backslash specially when it
is immediately followed by 'U' or 'u' and four hexadecimal digits.
* Tools/plist-0_9.dtd: document unicode escapes.
2003-08-02 Adam Fedor <fedor@gnu.org>
* Source/NSProxy.m: Fix limit.h -> limits.h

View file

@ -5025,23 +5025,13 @@ nodeToObject(GSXMLNode* node)
{
if (++pos < len)
{
if (buf[pos] == '/')
{
len--;
memcpy(&buf[pos], &buf[pos+1],
(len - pos) * sizeof(unichar));
}
else if (buf[pos] == 'u' || buf[pos] == 'U')
if ((buf[pos] == 'u' || buf[pos] == 'U')
&& (len >= pos + 4))
{
unichar val = 0;
unsigned i;
BOOL ok = YES;
if (len < pos + 4)
{
[NSException raise:
NSInternalInconsistencyException
format: @"Short escape sequence"];
}
for (i = 1; i < 5; i++)
{
unichar c = buf[pos + i];
@ -5060,61 +5050,22 @@ nodeToObject(GSXMLNode* node)
}
else
{
[NSException raise:
NSInternalInconsistencyException
format: @"bad hex escape sequence"];
ok = NO;
}
}
len -= 5;
memcpy(&buf[pos], &buf[pos+5],
(len - pos) * sizeof(unichar));
buf[pos - 1] = val;
}
else if (buf[pos] >= '0' && buf[pos] <= '7')
{
unichar val = 0;
unsigned i;
if (len < pos + 2)
if (ok == YES)
{
[NSException raise: NSInternalInconsistencyException
format: @"Short escape sequence"];
len -= 5;
memcpy(&buf[pos], &buf[pos+5],
(len - pos) * sizeof(unichar));
buf[pos - 1] = val;
}
for (i = 0; i < 3; i++)
{
unichar c = buf[pos + i];
if (c >= '0' && c <= '7')
{
val = (val << 3) + c - '0';
}
else
{
[NSException raise:
NSInternalInconsistencyException
format: @"bad octal escape sequence"];
}
}
len -= 3;
memcpy(&buf[pos], &buf[pos+3],
(len - pos) * sizeof(unichar));
buf[pos - 1] = val;
}
else
{
[NSException raise: NSInternalInconsistencyException
format: @"Short escape sequence"];
}
while (pos < len && buf[pos] != '\\')
{
pos++;
}
}
else
{
[NSException raise: NSInternalInconsistencyException
format: @"Short escape sequence"];
}
}
content = [NSString stringWithCharacters: buf length: len];
}

View file

@ -56,7 +56,13 @@
<!-- A key ... treated just like a string -->
<!ELEMENT key (#PCDATA)>
<!-- A string of characters. -->
<!-- A string of characters.
Not all unicodee characters are legal in PCDATA in XML,
so an escape mechanism is provided. A string containing
a sequence of the form \UXXXX or \uXXXX (where XXXX is a
hexadecimal number) will be replaced by thew appropriate
unicode character after the property list is parsed.
-->
<!ELEMENT string (#PCDATA)>
<!-- A real number [+/-]n.p[E[+/-]m] -->