@@ -20,12 +20,12 @@ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" -#import "OFFileURLHandler.h" -#import "OFURL.h" +#import "OFFileURIHandler.h" +#import "OFURI.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @@ -341,26 +341,27 @@ } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || - [OFFileURLHandler of_directoryExistsAtPath: self]); + [OFFileURIHandler of_directoryExistsAtPath: self]); } -- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost +- (OFString *)of_pathToURIPathWithPercentEncodedHost: + (OFString **)percentEncodedHost { OFString *path = self; if ([path hasPrefix: @"\\\\"]) { OFArray *components = path.pathComponents; if (components.count < 2) @throw [OFInvalidFormatException exception]; - *URLEncodedHost = [[components objectAtIndex: 1] - stringByURLEncodingWithAllowedCharacters: - [OFCharacterSet URLHostAllowedCharacterSet]]; + *percentEncodedHost = [[components objectAtIndex: 1] + stringByAddingPercentEncodingWithAllowedCharacters: + [OFCharacterSet URIHostAllowedCharacterSet]]; path = [OFString pathWithComponents: [components objectsInRange: OFMakeRange(2, components.count - 2)]]; } path = [path stringByReplacingOccurrencesOfString: @"\\" @@ -368,11 +369,12 @@ path = [@"/" stringByAppendingString: path]; return path; } -- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost +- (OFString *)of_URIPathToPathWithPercentEncodedHost: + (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"] && ![path hasSuffix: @":/"]) @@ -380,12 +382,13 @@ path = [path substringFromIndex: 1]; path = [path stringByReplacingOccurrencesOfString: @"/" withString: @"\\"]; - if (URLEncodedHost != nil) { - OFString *host = [URLEncodedHost stringByURLDecoding]; + if (percentEncodedHost != nil) { + OFString *host = [percentEncodedHost + stringByRemovingPercentEncoding]; if (path.length == 0) path = [OFString stringWithFormat: @"\\\\%@", host]; else path = [OFString stringWithFormat: @"\\\\%@\\%@", @@ -393,11 +396,11 @@ } return path; } -- (OFString *)of_pathComponentToURLPathComponent +- (OFString *)of_pathComponentToURIPathComponent { return [self stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; } @end