mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 17:32:17 +00:00
Percent escape strings before creating URLs
URLWithString will return nil if the string contains invalid URL characters (such as spaces). Percent escape the string before attempting to create an NSURL using it.
This commit is contained in:
@@ -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 */
|
||||||
|
|||||||
Reference in New Issue
Block a user