Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't escape space as "+" anymore. Though it looks nicer for web URLs…

…, it doesn't seem to work consistently across mail clients for URLs like mailto:foo@bar.com?subject=Hi+there+Mom so instead, just let the CF method we invoke do its usual thing in converting spaces to %20.
  • Loading branch information...
commit 5e1264ff8eac64561a918b7d03f9d98238d547a5 1 parent 5183eb9
@danwood danwood authored
Showing with 4 additions and 10 deletions.
  1. +4 −10 KSURLQueryUtilities.m
View
14 KSURLQueryUtilities.m
@@ -120,24 +120,18 @@ @implementation NSString (KSURLQueryUtilities)
RFC2396: Within a query component, the characters ";", "/", "?", ":", "@", "&", "=", "+", ",", and "$" are reserved.
+ Changed to NOT convert space into + ... while this is fine for web parameters, it doesn't work on mail clients reliably (e.g. mailto:foo@bar.com?subject=Hi+There+Mom)
*/
- (NSString *)ks_stringByAddingQueryComponentPercentEscapes;
{
- CFStringRef firstPass = CFURLCreateStringByAddingPercentEscapes(NULL,
+ CFStringRef converted = CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
- CFSTR(" "),
+ NULL,
CFSTR(";/?:@&=+,$%"),
kCFStringEncodingUTF8);
-
- NSMutableString *result = [(NSString *)firstPass mutableCopy];
- CFRelease(firstPass);
- [result replaceOccurrencesOfString:@" "
- withString:@"+"
- options:NSLiteralSearch
- range:NSMakeRange(0, [result length])];
-
+ NSString *result = NSMakeCollectable(converted);
return [result autorelease];
}

1 comment on commit 5e1264f

@dodgio

Synchronicity. I was just now using this method and stripping out "+" chars and replacing with "%20".

Please sign in to comment.
Something went wrong with that request. Please try again.