Differences From Artifact [2209074f5b]:
- File
src/OFURL.m
— part of check-in
[d2487bc7e1]
at
2014-07-07 00:50:01
on branch trunk
— OFURL: Don't include the leading "/" in path
While Cocoa includes it, RFC 1738 explicitly states that the "/" between
host / port and path is not part of the path. (user: js, size: 10442) [annotate] [blame] [check-ins using]
To Artifact [5ebb65d404]:
- File src/OFURL.m — part of check-in [65afbedbd4] at 2014-07-07 22:28:00 on branch trunk — OFURL: Allow all RFC 1808 compatible schemes (user: js, size: 10265) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * file. */ #include "config.h" #include <stdlib.h> #include <string.h> #import "OFURL.h" #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" | > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * file. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <ctype.h> #import "OFURL.h" #import "OFString.h" #import "OFArray.h" #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" |
︙ | ︙ | |||
53 54 55 56 57 58 59 | self = [super init]; @try { char *tmp, *tmp2; if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException | | | > > | > > | | | < | | | | | > | | < > | 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 | self = [super init]; @try { char *tmp, *tmp2; if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: [string UTF8StringLength]]; UTF8String = UTF8String2; if ((tmp = strstr(UTF8String, "://")) == NULL) @throw [OFInvalidFormatException exception]; for (tmp2 = UTF8String; tmp2 < tmp; tmp2++) *tmp2 = tolower((int)*tmp2); _scheme = [[OFString alloc] initWithUTF8String: UTF8String length: tmp - UTF8String]; UTF8String = tmp + 3; if ([_scheme isEqual: @"file"]) { _path = [[OFString alloc] initWithUTF8String: UTF8String]; return self; } if ((tmp = strchr(UTF8String, '/')) != NULL) { *tmp = '\0'; tmp++; } if ((tmp2 = strchr(UTF8String, '@')) != NULL) { |
︙ | ︙ | |||
116 117 118 119 120 121 122 | portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) @throw [OFInvalidFormatException exception]; _port = [portString decimalValue]; | < < < | | | 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 | portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) @throw [OFInvalidFormatException exception]; _port = [portString decimalValue]; objc_autoreleasePoolPop(pool); } else { _host = [[OFString alloc] initWithUTF8String: UTF8String]; if ([_scheme isEqual: @"http"]) _port = 80; else if ([_scheme isEqual: @"https"]) _port = 443; else if ([_scheme isEqual: @"ftp"]) _port = 21; } if ((UTF8String = tmp) != NULL) { if ((tmp = strchr(UTF8String, '#')) != NULL) { *tmp = '\0'; _fragment = [[OFString alloc] |
︙ | ︙ | |||
362 363 364 365 366 367 368 | - (OFString*)scheme { OF_GETTER(_scheme, true) } - (void)setScheme: (OFString*)scheme { | < < < | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | - (OFString*)scheme { OF_GETTER(_scheme, true) } - (void)setScheme: (OFString*)scheme { OF_SETTER(_scheme, scheme, true, 1) } - (OFString*)host { OF_GETTER(_host, true) } |
︙ | ︙ | |||
415 416 417 418 419 420 421 | - (OFString*)path { OF_GETTER(_path, true) } - (void)setPath: (OFString*)path { | < < < < | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | - (OFString*)path { OF_GETTER(_path, true) } - (void)setPath: (OFString*)path { OF_SETTER(_path, path, true, 1) } - (OFString*)parameters { OF_GETTER(_parameters, true) } |
︙ | ︙ | |||
473 474 475 476 477 478 479 | else if (_user != nil) [ret appendFormat: @"%@@", _user]; if (_host != nil) [ret appendString: _host]; if (([_scheme isEqual: @"http"] && _port != 80) || | | > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | else if (_user != nil) [ret appendFormat: @"%@@", _user]; if (_host != nil) [ret appendString: _host]; if (([_scheme isEqual: @"http"] && _port != 80) || ([_scheme isEqual: @"https"] && _port != 443) || ([_scheme isEqual: @"ftp"] && _port != 21)) [ret appendFormat: @":%u", _port]; if (_path != nil) [ret appendFormat: @"/%@", _path]; if (_parameters != nil) [ret appendFormat: @";%@", _parameters]; |
︙ | ︙ |