Index: src/OFString+URLEncoding.h ================================================================== --- src/OFString+URLEncoding.h +++ src/OFString+URLEncoding.h @@ -32,14 +32,24 @@ * * @return A new autoreleased string */ - (OFString*)stringByURLEncoding; +/*! + * @brief Encodes a string for use in a URL, but does not escape the specified + * ignored characters. + * + * @param ignored A C string of characters that should not be escaped + * + * @return A new autoreleased string + */ +- (OFString*)stringByURLEncodingWithIgnoredCharacters: (const char*)ignored; + /*! * @brief Decodes a string used in a URL. * * @return A new autoreleased string */ - (OFString*)stringByURLDecoding; @end OF_ASSUME_NONNULL_END Index: src/OFString+URLEncoding.m ================================================================== --- src/OFString+URLEncoding.m +++ src/OFString+URLEncoding.m @@ -29,10 +29,15 @@ int _OFString_URLEncoding_reference; @implementation OFString (URLEncoding) - (OFString*)stringByURLEncoding { + return [self stringByURLEncodingWithIgnoredCharacters: ""]; +} + +- (OFString*)stringByURLEncodingWithIgnoredCharacters: (const char*)ignored +{ void *pool = objc_autoreleasePoolPush(); const char *string = [self UTF8String]; char *retCString; size_t i; OFString *ret; @@ -53,11 +58,12 @@ * make sure it's always interpreted correctly. */ if (!(*string & 0x80) && (isalnum((int)*string) || *string == '$' || *string == '-' || *string == '_' || *string == '.' || *string == '!' || *string == '*' || - *string == '(' || *string == ')' || *string == ',')) + *string == '(' || *string == ')' || *string == ',' || + strchr(ignored, *string) != NULL)) retCString[i++] = *string; else { uint8_t high, low; high = *string >> 4;