Differences From Artifact [800b8aa913]:
- File
src/OFMutableURI.m
— part of check-in
[13ead1212f]
at
2022-10-11 00:18:40
on branch trunk
— OFURI: Remove percentEncodedScheme
The scheme does not allow percent encoding. (user: js, size: 10413) [annotate] [blame] [check-ins using]
To Artifact [375c07c449]:
- File
src/OFMutableURI.m
— part of check-in
[3e455c4839]
at
2022-10-11 19:27:09
on branch trunk
— OFURI: Make scheme and path nonnull
This is as per the RFC, which says the scheme and path can never be
missing, while the path can be empty. (user: js, size: 10704) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFMutableURI.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" @implementation OFMutableURI @dynamic scheme, host, percentEncodedHost, port, user, percentEncodedUser; @dynamic password, percentEncodedPassword, path, percentEncodedPath; @dynamic pathComponents, query, percentEncodedQuery, queryItems, fragment; @dynamic percentEncodedFragment; | > | | > > > > > > > > > > > > > > > | 12 13 14 15 16 17 18 19 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 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFMutableURI.h" #import "OFURI+Private.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" @implementation OFMutableURI @dynamic scheme, host, percentEncodedHost, port, user, percentEncodedUser; @dynamic password, percentEncodedPassword, path, percentEncodedPath; @dynamic pathComponents, query, percentEncodedQuery, queryItems, fragment; @dynamic percentEncodedFragment; + (instancetype)URIWithScheme: (OFString *)scheme { return [[[self alloc] initWithScheme: scheme] autorelease]; } - (instancetype)initWithScheme: (OFString *)scheme { self = [super of_init]; @try { self.scheme = scheme; _percentEncodedPath = @""; } @catch (id e) { [self release]; @throw e; } return self; } - (void)setScheme: (OFString *)scheme { void *pool = objc_autoreleasePoolPush(); OFString *old = _scheme; |
︙ | ︙ | |||
172 173 174 175 176 177 178 | objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedPath: (OFString *)percentEncodedPath { OFString *old; | < | | < < < < < | | > > > > | 188 189 190 191 192 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 | objc_autoreleasePoolPop(pool); } - (void)setPercentEncodedPath: (OFString *)percentEncodedPath { OFString *old; OFURIVerifyIsEscaped(percentEncodedPath, [OFCharacterSet URIPathAllowedCharacterSet], true); old = _percentEncodedPath; _percentEncodedPath = [percentEncodedPath copy]; [old release]; } - (void)setPathComponents: (OFArray *)components { void *pool = objc_autoreleasePoolPush(); if (components.count == 0) @throw [OFInvalidFormatException exception]; if ([components.firstObject isEqual: @"/"]) { OFMutableArray *mutComponents = [[components mutableCopy] autorelease]; [mutComponents replaceObjectAtIndex: 0 withObject: @""]; components = mutComponents; } self.path = [components componentsJoinedByString: @"/"]; objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query |
︙ | ︙ | |||
361 362 363 364 365 366 367 | _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)standardizePath { | | | < < < < < < < < > | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | _percentEncodedPath = [path retain]; objc_autoreleasePoolPop(pool); } - (void)standardizePath { void *pool = objc_autoreleasePoolPush(); OFMutableArray OF_GENERIC(OFString *) *array; bool done = false, startsWithEmpty, endsWithEmpty; OFString *path; array = [[[_percentEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; endsWithEmpty = ([array.lastObject length] == 0); startsWithEmpty = ([array.firstObject length] == 0); while (!done) { size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { |
︙ | ︙ | |||
407 408 409 410 411 412 413 | done = false; break; } } } | > | | | | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | done = false; break; } } } if (startsWithEmpty) [array insertObject: @"" atIndex: 0]; if (endsWithEmpty) [array addObject: @""]; path = [array componentsJoinedByString: @"/"]; if (startsWithEmpty && path.length == 0) path = @"/"; self.percentEncodedPath = path; objc_autoreleasePoolPop(pool); } - (void)makeImmutable { object_setClass(self, [OFURI class]); } @end |