From 12340d75247a6a24799fa63324d9136584cdc842 Mon Sep 17 00:00:00 2001 From: CaS Date: Thu, 7 Aug 2003 07:17:03 +0000 Subject: [PATCH] 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 --- ChangeLog | 7 +++++ Source/NSString.m | 67 ++++++--------------------------------------- Tools/plist-0_9.dtd | 8 +++++- 3 files changed, 23 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e1277248..713823423 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-08-07 Richard Frith-Macdonald + + * 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 * Source/NSProxy.m: Fix limit.h -> limits.h diff --git a/Source/NSString.m b/Source/NSString.m index ddc7bb799..a77bfc5ef 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -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]; } diff --git a/Tools/plist-0_9.dtd b/Tools/plist-0_9.dtd index 773848a14..3051f36ec 100644 --- a/Tools/plist-0_9.dtd +++ b/Tools/plist-0_9.dtd @@ -56,7 +56,13 @@ - +