Apply patch by Jens Alfke with minor changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34902 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-03-07 08:37:54 +00:00
parent f633f6b2fc
commit 1a55779dd7
4 changed files with 46 additions and 5 deletions

View file

@ -1,3 +1,11 @@
2012-03-01 Jens Alfke <jens@mooseyard.com>
* Headers/GNUstepBase/NSURL+GNUstepBase.h:
* Source/Additions/NSURL+GNUstepBase.m:
* Source/NSURL.m:
New -pathWithEscapes method to enable differentiation between '/'
characters in the original path and '%2F' escapes in it.
2012-03-06 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLNode.m (+initialize): Add workaround for Windows

View file

@ -56,6 +56,14 @@ extern "C" {
/** Returns the full path for this URL including any trailing slash.
*/
- (NSString*) fullPath;
/** Returns the full path for this URL, without decoding percent-escapes.<br />
* This is useful if you need to distinguish between "/" and "%2F" in the path.
* The normal -path method will convert all "%2F" value in the path into "/"
* so that you have no way of knowing whether a "/" is part of a path component
* ir is a path separator.
*/
- (NSString*) pathWithEscapes;
@end
#endif /* OS_API_VERSION */

View file

@ -99,7 +99,11 @@
@end
#ifndef GNUSTEP
#import <CFURL.h>
@implementation NSURL (GNUstepBase)
/* For efficiency this is built in to the main library.
*/
- (NSString*) fullPath
@ -122,6 +126,14 @@
s = [s substringFromIndex: r.location];
return s;
}
/* For efficiency this is built in to the main library.
*/
- (NSString*) pathWithEscapes
{
return CFURLCopyPath(self);
}
@end
#endif

View file

@ -1415,7 +1415,7 @@ static NSUInteger urlAlign;
return fragment;
}
- (char*) _path: (char*)buf
- (char*) _path: (char*)buf withEscapes: (BOOL)withEscapes
{
char *ptr = buf;
char *tmp = buf;
@ -1472,7 +1472,10 @@ static NSUInteger urlAlign;
}
}
unescape(buf, buf);
if (!withEscapes)
{
unescape(buf, buf);
}
#if defined(__MINGW__)
/* On windows a file URL path may be of the form C:\xxx (ie we should
@ -1602,7 +1605,7 @@ static NSUInteger urlAlign;
return password;
}
- (NSString*) path
- (NSString*) _pathWithEscapes: (BOOL)withEscapes
{
NSString *path = nil;
unsigned int len = 3;
@ -1632,7 +1635,7 @@ static NSUInteger urlAlign;
char *ptr;
char *tmp;
ptr = [self _path: buf];
ptr = [self _path: buf withEscapes: withEscapes];
/* Remove any trailing '/' from the path for MacOS-X compatibility.
*/
@ -1647,6 +1650,11 @@ static NSUInteger urlAlign;
return path;
}
- (NSString*) path
{
return [self _pathWithEscapes: NO];
}
- (NSArray*) pathComponents
{
return [[self path] pathComponents];
@ -2036,10 +2044,15 @@ static NSUInteger urlAlign;
char buf[len];
char *ptr;
ptr = [self _path: buf];
ptr = [self _path: buf withEscapes: NO];
path = [NSString stringWithUTF8String: ptr];
}
return path;
}
- (NSString*) pathWithEscapes
{
return [self _pathWithEscapes: YES];
}
@end