Differences From Artifact [f6b587c9bc]:
- File
src/OFMutableURL.m
— part of check-in
[5f7305c659]
at
2017-10-31 21:39:36
on branch trunk
— OFURL: URL-encode according to RFC 3986
This also means the parameters go away and get folded into the path. (user: js, size: 2452) [annotate] [blame] [check-ins using]
To Artifact [b9f96c6e08]:
- File
src/OFMutableURL.m
— part of check-in
[a15b403a11]
at
2017-11-06 23:01:57
on branch trunk
— OFURL: Store the URL-encoded version internally
This allows retrieving it how it was originally stored, which is useful
for example for query strings, as these often URL-encode allowed
characters in order to allow pairs of the form foo=bar&bar=qux. (user: js, size: 4696) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
21 22 23 24 25 26 27 | #import "OFNumber.h" #import "OFString.h" #import "OFURL+Private.h" #import "OFInvalidFormatException.h" @implementation OFMutableURL | | | > > > > > > > > > > > > | | > > > > > > > > > > | | > > > > > > > > > > | | > > > > > > > > > > > | | > > > > > > > > > > | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | #import "OFNumber.h" #import "OFString.h" #import "OFURL+Private.h" #import "OFInvalidFormatException.h" @implementation OFMutableURL @dynamic scheme, URLEncodedScheme, host, URLEncodedHost, port, user; @dynamic URLEncodedUser, password, URLEncodedPassword, path, URLEncodedPath; @dynamic pathComponents, query, URLEncodedQuery, fragment, URLEncodedFragment; + (instancetype)URL { return [[[self alloc] init] autorelease]; } - (instancetype)init { return [super of_init]; } - (void)setScheme: (OFString *)scheme { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedScheme: [scheme stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLSchemeAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedScheme: (OFString *)URLEncodedScheme { OFString *old = _URLEncodedScheme; _URLEncodedScheme = [URLEncodedScheme copy]; [old release]; } - (void)setHost: (OFString *)host { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedHost: [host stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLHostAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedHost: (OFString *)URLEncodedHost { OFString *old = _URLEncodedHost; _URLEncodedHost = [URLEncodedHost copy]; [old release]; } - (void)setPort: (OFNumber *)port { OFNumber *old = _port; _port = [port copy]; [old release]; } - (void)setUser: (OFString *)user { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedUser: [user stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLUserAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedUser: (OFString *)URLEncodedUser { OFString *old = _URLEncodedUser; _URLEncodedUser = [URLEncodedUser copy]; [old release]; } - (void)setPassword: (OFString *)password { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedPassword: [password stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPasswordAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedPassword: (OFString *)URLEncodedPassword { OFString *old = _URLEncodedPassword; _URLEncodedPassword = [URLEncodedPassword copy]; [old release]; } - (void)setPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedPath: [path stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPathAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedPath: (OFString *)URLEncodedPath { OFString *old = _URLEncodedPath; _URLEncodedPath = [URLEncodedPath copy]; [old release]; } - (void)setPathComponents: (OFArray *)components { void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
98 99 100 101 102 103 104 | [self setPath: [components componentsJoinedByString: @"/"]]; objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query { | > > > > > > > > > > > | | > > > > > > > > > > > | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | [self setPath: [components componentsJoinedByString: @"/"]]; objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedQuery: [query stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLQueryAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedQuery: (OFString *)URLEncodedQuery { OFString *old = _URLEncodedQuery; _URLEncodedQuery = [URLEncodedQuery copy]; [old release]; } - (void)setFragment: (OFString *)fragment { void *pool = objc_autoreleasePoolPush(); [self setURLEncodedFragment: [fragment stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLFragmentAllowedCharacterSet]]]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedFragment: (OFString *)URLEncodedFragment { OFString *old = _URLEncodedFragment; _URLEncodedFragment = [URLEncodedFragment copy]; [old release]; } - (id)copy { OFMutableURL *copy = [self mutableCopy]; |
︙ | ︙ |