Differences From Artifact [134edb9cf7]:
- File
src/OFString+URLEncoding.m
— part of check-in
[32bc855af9]
at
2016-07-02 23:35:54
on branch trunk
— OFString+URLEncoding.m: Do not parse + as space
This should only be done for the query string. (user: js, size: 3695) [annotate] [blame] [check-ins using]
To Artifact [9b57fed9b2]:
- File
src/OFString+URLEncoding.m
— part of check-in
[516517deb3]
at
2016-08-21 14:00:20
on branch trunk
— OFURL: Do not URL decode and reencode parts
URL decoding and reencoding is not lossless: For example, if the query
was foo=bar&qux=foo%25bar, it will be decoded to foo=bar&qux=foo&bar and
then reencoded to foo=bar%25qux=foo%25bar, which is a different thing.The only way to solve this is to let the application handle the URL
decoding and encoding according to its own rules, as those might be
different depending on the application. (user: js, size: 3583) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
27 28 29 30 31 32 33 | /* Reference for static linking */ int _OFString_URLEncoding_reference; @implementation OFString (URLEncoding) - (OFString*)stringByURLEncoding { | | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* Reference for static linking */ int _OFString_URLEncoding_reference; @implementation OFString (URLEncoding) - (OFString*)stringByURLEncoding { return [self stringByURLEncodingWithAllowedCharacters: "$-_.!*()"]; } - (OFString*)stringByURLEncodingWithAllowedCharacters: (const char*)allowed { void *pool = objc_autoreleasePoolPush(); const char *string = [self UTF8String]; char *retCString; size_t i; OFString *ret; |
︙ | ︙ | |||
55 56 57 58 59 60 61 | unsigned char c = *string; /* * '+' is also listed in RFC 1738, however, '+' is sometimes * interpreted as space in HTTP. Therefore always escape it to * make sure it's always interpreted correctly. */ | | < < | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | unsigned char c = *string; /* * '+' is also listed in RFC 1738, however, '+' is sometimes * interpreted as space in HTTP. Therefore always escape it to * make sure it's always interpreted correctly. */ if (!(c & 0x80) && (isalnum(c) || strchr(allowed, c) != NULL)) retCString[i++] = c; else { unsigned char high, low; high = c >> 4; low = c & 0x0F; |
︙ | ︙ |