@@ -85,19 +85,19 @@ @throw [OFInvalidFormatException exception]; for (tmp2 = UTF8String; tmp2 < tmp; tmp2++) *tmp2 = tolower((unsigned char)*tmp2); - _scheme = [[[OFString stringWithUTF8String: UTF8String - length: tmp - UTF8String] - stringByURLDecoding] copy]; + _scheme = [[OFString alloc] + initWithUTF8String: UTF8String + length: tmp - UTF8String]; UTF8String = tmp + 3; if ([_scheme isEqual: @"file"]) { - _path = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + _path = [[OFString alloc] + initWithUTF8String: UTF8String]; objc_autoreleasePoolPop(pool); return self; } @@ -114,17 +114,17 @@ if ((tmp3 = strchr(UTF8String, ':')) != NULL) { *tmp3 = '\0'; tmp3++; - _user = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; - _password = [[[OFString stringWithUTF8String: - tmp3] stringByURLDecoding] copy]; + _user = [[OFString alloc] + initWithUTF8String: UTF8String]; + _password = [[OFString alloc] + initWithUTF8String: tmp3]; } else - _user = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + _user = [[OFString alloc] + initWithUTF8String: UTF8String]; UTF8String = tmp2; } if ((tmp2 = strchr(UTF8String, ':')) != NULL) { @@ -132,12 +132,12 @@ OFString *portString; *tmp2 = '\0'; tmp2++; - _host = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + _host = [[OFString alloc] + initWithUTF8String: UTF8String]; pool = objc_autoreleasePoolPush(); portString = [OFString stringWithUTF8String: tmp2]; if ([portString decimalValue] > 65535) @@ -145,12 +145,12 @@ _port = [portString decimalValue]; objc_autoreleasePoolPop(pool); } else { - _host = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + _host = [[OFString alloc] + initWithUTF8String: UTF8String]; if ([_scheme isEqual: @"http"]) _port = 80; else if ([_scheme isEqual: @"https"]) _port = 443; @@ -160,30 +160,33 @@ if ((UTF8String = tmp) != NULL) { if ((tmp = strchr(UTF8String, '#')) != NULL) { *tmp = '\0'; - _fragment = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _fragment = [[OFString alloc] + initWithUTF8String: tmp + 1]; } if ((tmp = strchr(UTF8String, '?')) != NULL) { *tmp = '\0'; - _query = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _query = [[OFString alloc] + initWithUTF8String: tmp + 1]; } if ((tmp = strchr(UTF8String, ';')) != NULL) { *tmp = '\0'; - _parameters = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _parameters = [[OFString alloc] + initWithUTF8String: tmp + 1]; } - _path = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + UTF8String--; + *UTF8String = '/'; + + _path = [[OFString alloc] + initWithUTF8String: UTF8String]; } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @@ -222,34 +225,33 @@ UTF8String = UTF8String2; if ((tmp = strchr(UTF8String, '#')) != NULL) { *tmp = '\0'; - _fragment = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _fragment = [[OFString alloc] + initWithUTF8String: tmp + 1]; } if ((tmp = strchr(UTF8String, '?')) != NULL) { *tmp = '\0'; - _query = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _query = [[OFString alloc] + initWithUTF8String: tmp + 1]; } if ((tmp = strchr(UTF8String, ';')) != NULL) { *tmp = '\0'; - _parameters = [[[OFString stringWithUTF8String: - tmp + 1] stringByURLDecoding] copy]; + _parameters = [[OFString alloc] + initWithUTF8String: tmp + 1]; } if (*UTF8String == '/') - _path = [[[OFString stringWithUTF8String: - UTF8String + 1] stringByURLDecoding] copy]; + _path = [[OFString alloc] + initWithUTF8String: UTF8String]; else { OFString *path, *s; - path = [[[OFString stringWithUTF8String: - UTF8String] stringByURLDecoding] copy]; + path = [OFString stringWithUTF8String: UTF8String]; if ([URL->_path hasSuffix: @"/"]) s = [URL->_path stringByAppendingString: path]; else s = [OFString stringWithFormat: @"%@/../%@", @@ -386,48 +388,48 @@ - (OFString*)string { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); - [ret appendFormat: @"%@://", [_scheme stringByURLEncoding]]; + [ret appendFormat: @"%@://", _scheme]; if ([_scheme isEqual: @"file"]) { if (_path != nil) - [ret appendString: [_path - stringByURLEncodingWithIgnoredCharacters: "/"]]; + [ret appendString: _path]; objc_autoreleasePoolPop(pool); return ret; } if (_user != nil && _password != nil) - [ret appendFormat: @"%@:%@@", - [_user stringByURLEncoding], - [_password stringByURLEncoding]]; + [ret appendFormat: @"%@:%@@", _user, _password]; else if (_user != nil) - [ret appendFormat: @"%@@", [_user stringByURLEncoding]]; + [ret appendFormat: @"%@@", _user]; if (_host != nil) - [ret appendString: [_host stringByURLEncoding]]; + [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 stringByURLEncodingWithIgnoredCharacters: "/"]]; + if (_path != nil) { + if (![_path hasPrefix: @"/"]) + @throw [OFInvalidFormatException exception]; + + [ret appendString: _path]; + } if (_parameters != nil) - [ret appendFormat: @";%@", [_parameters stringByURLEncoding]]; + [ret appendFormat: @";%@", _parameters]; if (_query != nil) - [ret appendFormat: @"?%@", [_query stringByURLEncoding]]; + [ret appendFormat: @"?%@", _query]; if (_fragment != nil) - [ret appendFormat: @"#%@", [_fragment stringByURLEncoding]]; + [ret appendFormat: @"#%@", _fragment]; objc_autoreleasePoolPop(pool); [ret makeImmutable];