adium 2619:823d05c896a9: try unescaping a url first, then re-esc...

commits at adium.im commits at adium.im
Sat Aug 22 19:46:08 UTC 2009


details:	http://hg.adium.im/adium/rev/823d05c896a9
revision:	2619:823d05c896a9
author:		Stephen Holt <sholt at adium.im>
date:		Sat Aug 22 15:44:29 2009 -0400

try unescaping a url first, then re-escape it.  If, for some reason, unescaping fails, fall back on the originating string.  Fixes #12850.

diffs (27 lines):

diff -r 3571e5f41300 -r 823d05c896a9 Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m
--- a/Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m	Fri Aug 21 20:25:45 2009 -0700
+++ b/Frameworks/AutoHyperlinks Framework/Source/AHMarkedHyperlink.m	Sat Aug 22 15:44:29 2009 -0400
@@ -101,13 +101,18 @@
 
 - (void)setURLFromString:(NSString *)inString
 {
-	NSString	*linkString;
+	NSString	*linkString, *preString;
 
+	preString = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, 
+																					(CFStringRef)inString, 
+																					CFSTR(""), 
+																					kCFStringEncodingUTF8);
+	
 	linkString = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
-	                                        (CFStringRef)inString,
-	                                        (CFStringRef)@"#[]",
-	                                        NULL,
-	                                        kCFStringEncodingUTF8); // kCFStringEncodingISOLatin1 );
+																	 preString? (CFStringRef)preString : (CFStringRef)inString,
+																	 (CFStringRef)@"#[]",
+																	 NULL,
+																	 kCFStringEncodingUTF8); // kCFStringEncodingISOLatin1 );
 
 	[linkURL release];
 	linkURL = [[NSURL alloc] initWithString:linkString];



More information about the commits mailing list