Merge pull request #216 from jamesrhurst/escape-url

Percent escape strings before creating URLs
This commit is contained in:
Michael Starke
2014-08-16 08:40:37 +02:00

View File

@@ -616,10 +616,10 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
- (void)openURL:(id)sender { - (void)openURL:(id)sender {
KPKEntry *selectedEntry = [self _clickedOrSelectedEntry]; KPKEntry *selectedEntry = [self _clickedOrSelectedEntry];
if(selectedEntry && [selectedEntry.url length] > 0) { if(selectedEntry && [selectedEntry.url length] > 0) {
NSURL *webURL = [NSURL URLWithString:selectedEntry.url]; NSURL *webURL = [NSURL URLWithString:[selectedEntry.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *scheme = [webURL scheme]; NSString *scheme = [webURL scheme];
if(!scheme) { if(!scheme) {
webURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", selectedEntry.url]]; webURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [selectedEntry.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
} }
[[NSWorkspace sharedWorkspace] openURL:webURL]; [[NSWorkspace sharedWorkspace] openURL:webURL];
/* Add custom browser support */ /* Add custom browser support */