Differences From 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]
To Artifact [e4b33c27ce]:
- File src/OFMutableURL.m — part of check-in [b2ee854268] at 2017-11-14 00:23:14 on branch trunk — OFURL: Always verify the URL-encoded versions (user: js, size: 5821) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
20 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 | #import "OFArray.h" #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(); | > > > < | | > > > > > > > | > | | > > | > > > > > > | | > > | > > > > > > | | | > > > > > > > | > | | > > | > > > > > | 20 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 140 141 142 143 144 145 146 147 148 149 150 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 | #import "OFArray.h" #import "OFNumber.h" #import "OFString.h" #import "OFURL+Private.h" #import "OFInvalidFormatException.h" extern void of_url_verify_escaped(OFString *, OFCharacterSet *); @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(); OFString *old = _URLEncodedScheme; _URLEncodedScheme = [[scheme stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLSchemeAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedScheme: (OFString *)URLEncodedScheme { OFString *old; of_url_verify_escaped(URLEncodedScheme, [OFCharacterSet URLSchemeAllowedCharacterSet]); old = _URLEncodedScheme; _URLEncodedScheme = [URLEncodedScheme copy]; [old release]; } - (void)setHost: (OFString *)host { void *pool = objc_autoreleasePoolPush(); OFString *old = _URLEncodedHost; _URLEncodedHost = [[host stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLHostAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedHost: (OFString *)URLEncodedHost { OFString *old; of_url_verify_escaped(URLEncodedHost, [OFCharacterSet URLHostAllowedCharacterSet]); 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(); OFString *old = _URLEncodedUser; _URLEncodedUser = [[user stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLUserAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedUser: (OFString *)URLEncodedUser { OFString *old; of_url_verify_escaped(URLEncodedUser, [OFCharacterSet URLUserAllowedCharacterSet]); old = _URLEncodedUser; _URLEncodedUser = [URLEncodedUser copy]; [old release]; } - (void)setPassword: (OFString *)password { void *pool = objc_autoreleasePoolPush(); OFString *old = _URLEncodedPassword; _URLEncodedPassword = [[password stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPasswordAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedPassword: (OFString *)URLEncodedPassword { OFString *old; of_url_verify_escaped(URLEncodedPassword, [OFCharacterSet URLPasswordAllowedCharacterSet]); old = _URLEncodedPassword; _URLEncodedPassword = [URLEncodedPassword copy]; [old release]; } - (void)setPath: (OFString *)path { void *pool = objc_autoreleasePoolPush(); OFString *old = _URLEncodedPath; _URLEncodedPath = [[path stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPathAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedPath: (OFString *)URLEncodedPath { OFString *old; of_url_verify_escaped(URLEncodedPath, [OFCharacterSet URLPathAllowedCharacterSet]); old = _URLEncodedPath; _URLEncodedPath = [URLEncodedPath copy]; [old release]; } - (void)setPathComponents: (OFArray *)components { void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
152 153 154 155 156 157 158 159 | objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); | > < | | > > | > > > > > > | | | > > > > > > > | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query { void *pool = objc_autoreleasePoolPush(); OFString *old = _URLEncodedQuery; _URLEncodedQuery = [[query stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLQueryAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedQuery: (OFString *)URLEncodedQuery { OFString *old; of_url_verify_escaped(URLEncodedQuery, [OFCharacterSet URLQueryAllowedCharacterSet]); old = _URLEncodedQuery; _URLEncodedQuery = [URLEncodedQuery copy]; [old release]; } - (void)setFragment: (OFString *)fragment { void *pool = objc_autoreleasePoolPush(); OFString *old = _URLEncodedFragment; _URLEncodedFragment = [[fragment stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLFragmentAllowedCharacterSet]] copy]; [old release]; objc_autoreleasePoolPop(pool); } - (void)setURLEncodedFragment: (OFString *)URLEncodedFragment { OFString *old; of_url_verify_escaped(URLEncodedFragment, [OFCharacterSet URLFragmentAllowedCharacterSet]); old = _URLEncodedFragment; _URLEncodedFragment = [URLEncodedFragment copy]; [old release]; } - (id)copy { OFMutableURL *copy = [self mutableCopy]; |
︙ | ︙ |