@@ -141,10 +141,38 @@ UTF8String++; } return hasColon; } + +OFURI * +OFURIForFileInArchive(OFString *scheme, OFString *path, OFURI *archive) +{ + static OFOnceControl onceControl = OFOnceControlInitValue; + OFMutableURI *URI = [OFMutableURI URI]; + void *pool = objc_autoreleasePoolPush(); + OFString *archiveURI; + + OFOnce(&onceControl, + initURIPathAllowedCharacterSetWithoutExclamationMark); + + path = [path stringByAddingPercentEncodingWithAllowedCharacters: + URIPathAllowedCharacterSetWithoutExclamationMark]; + archiveURI = [archive.string + stringByAddingPercentEncodingWithAllowedCharacters: + URIPathAllowedCharacterSetWithoutExclamationMark]; + + URI.scheme = scheme; + URI.percentEncodedPath = [OFString stringWithFormat: @"%@!%@", + archiveURI, path]; + + [URI makeImmutable]; + + objc_autoreleasePoolPop(pool); + + return URI; +} @implementation OFURIAllowedCharacterSetBase - (instancetype)autorelease { return self; @@ -445,19 +473,10 @@ OFOnce(&URIQueryOrFragmentAllowedCharacterSetOnce, initURIQueryOrFragmentAllowedCharacterSet); return URIQueryOrFragmentAllowedCharacterSet; } - -+ (OFCharacterSet *)of_URIPathAllowedCharacterSetWithoutExclamationMark -{ - static OFOnceControl onceControl = OFOnceControlInitValue; - OFOnce(&onceControl, - initURIPathAllowedCharacterSetWithoutExclamationMark); - - return URIPathAllowedCharacterSetWithoutExclamationMark; -} @end @implementation OFURI + (instancetype)URI {