diff --git a/ChangeLog b/ChangeLog index 894bd2a44..927e267d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2011-06-17 Richard Frith-Macdonald + * Source/NSXMLParser.m: Fix error with whitespace at end of attributes. * Headers/GNUstepBase/NSURL+GNUstepBase.h: Add method to build a URL from separate components. * Headers/Foundation/NSURL.h: Add some OSX 10.6 methods for path diff --git a/Headers/Foundation/NSURL.h b/Headers/Foundation/NSURL.h index f26151d1d..9bdd129dc 100644 --- a/Headers/Foundation/NSURL.h +++ b/Headers/Foundation/NSURL.h @@ -97,6 +97,18 @@ GS_EXPORT NSString* const NSURLFileScheme; */ - (id) initFileURLWithPath: (NSString*)aPath; +#if OS_API_VERSION(100500,GS_API_LATEST) +/** + * Initialise as a file URL with the specified path (which must + * be a valid path on the local filesystem).
+ * Converts relative paths to absolute ones.
+ * Appends a trailing slash to the path when necessary if it + * specifies a directory.
+ * Calls -initWithScheme:host:path: + */ +- (id) initFileURLWithPath: (NSString*)aPath isDirectory: (BOOL)isDir; +#endif + /** * Initialise by building a URL string from the supplied parameters * and calling -initWithString:relativeToURL:
diff --git a/Source/NSURL.m b/Source/NSURL.m index e22395d5b..61994491b 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -657,6 +657,34 @@ static NSUInteger urlAlign; return self; } +- (id) initFileURLWithPath: (NSString*)aPath isDirectory: (BOOL)isDir +{ + NSFileManager *mgr = [NSFileManager defaultManager]; + BOOL flag = NO; + + if ([aPath isAbsolutePath] == NO) + { + aPath = [[mgr currentDirectoryPath] + stringByAppendingPathComponent: aPath]; + } + if ([mgr fileExistsAtPath: aPath isDirectory: &flag] == YES) + { + if ([aPath isAbsolutePath] == NO) + { + aPath = [aPath stringByStandardizingPath]; + } + isDir = flag; + } + if (isDir == YES && [aPath hasSuffix: @"/"] == NO) + { + aPath = [aPath stringByAppendingString: @"/"]; + } + self = [self initWithScheme: NSURLFileScheme + host: @"localhost" + path: aPath]; + return self; +} + - (id) initWithScheme: (NSString*)aScheme host: (NSString*)aHost path: (NSString*)aPath diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 3af50a555..a3c94ec7a 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -1903,6 +1903,10 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); [attributes setObject: val forKey: arg]; [val release]; c = cget(); // get character behind qarg value + while (isspace(c)) + { + c = cget(); + } } else // implicit {