Make property list validation stricter ... should be ascii data with

escape sequences for anything else, otherwise it would be non-portable
between systems with different default character encodings.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19628 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-06-27 09:07:36 +00:00
parent 587254b3f9
commit 635e5188fd
2 changed files with 20 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2004-06-27 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/plparse.m: Check for and report illegal (non-ascii) characters
in property list. A property list should use \UXXXX escape sequences
for non-ascii data.
2004-06-26 17:12 Alexander Malmberg <alexander@malmberg.org>
* Source/NSUserDefaults.m (read_only): Remove.

View file

@ -61,6 +61,12 @@ main(int argc, char** argv, char **env)
}
else
{
NSCharacterSet *cs;
cs = [NSCharacterSet characterSetWithRange: NSMakeRange(1, 127)];
cs = [cs invertedSet];
for (i = 1; i < [args count]; i++)
{
NSString *file = [args objectAtIndex: i];
@ -68,11 +74,16 @@ main(int argc, char** argv, char **env)
NS_DURING
{
NSString *myString;
id result;
id result;
NSRange r;
myString = [NSString stringWithContentsOfFile: file];
result = [myString propertyList];
if (result == nil)
if (myString == nil)
GSPrintf(stderr, @"Parsing '%@' - not valid string\n", file);
else if ((r = [myString rangeOfCharacterFromSet: cs]).length > 0)
GSPrintf(stderr, @"Parsing '%@' - bad char '\\U%04x' at %d\n",
file, [myString characterAtIndex: r.location], r.location);
else if ((result = [myString propertyList]) == nil)
GSPrintf(stderr, @"Parsing '%@' - nil property list\n", file);
else if ([result isKindOfClass: [NSDictionary class]] == YES)
GSPrintf(stderr, @"Parsing '%@' - a dictionary\n", file);