iOS web browser with a focus on security and privacy
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

HostSettings: allow universal link protection to be disabled per-host

In case this is causing issues, it can be disabled temporarily or
for a single host.

+37 -10
+2
Endless/HostSettings.h
··· 35 35 36 36 #define HOST_SETTINGS_KEY_USER_AGENT @"user_agent" 37 37 38 + #define HOST_SETTINGS_KEY_UNIVERSAL_LINK_PROTECTION @"universal_link_protection" 39 + 38 40 @interface HostSettings : NSObject 39 41 40 42 @property (strong) NSMutableDictionary *dict;
+1
Endless/HostSettings.m
··· 27 27 HOST_SETTINGS_KEY_WHITELIST_COOKIES: HOST_SETTINGS_VALUE_NO, 28 28 HOST_SETTINGS_KEY_USER_AGENT: @"", 29 29 HOST_SETTINGS_KEY_ALLOW_WEBRTC: HOST_SETTINGS_VALUE_NO, 30 + HOST_SETTINGS_KEY_UNIVERSAL_LINK_PROTECTION: HOST_SETTINGS_VALUE_YES, 30 31 }; 31 32 } 32 33
+16
Endless/HostSettingsController.m
··· 217 217 [section addFormRow:row]; 218 218 [form addFormSection:section]; 219 219 } 220 + 221 + /* universal link protection */ 222 + { 223 + XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:HOST_SETTINGS_KEY_UNIVERSAL_LINK_PROTECTION rowType:XLFormRowDescriptorTypeSelectorActionSheet title:NSLocalizedString(@"Universal Link Protection", nil)]; 224 + [self setYesNoSelectorOptionsForSetting:HOST_SETTINGS_KEY_UNIVERSAL_LINK_PROTECTION host:host row:row withDefault:(![host isDefault])]; 225 + 226 + section = [XLFormSectionDescriptor formSection]; 227 + [section setTitle:@""]; 228 + [section setFooterTitle:([host isDefault] 229 + ? NSLocalizedString(@"Handle tapping on links in a non-standard way to avoid possibly opening external applications", nil) 230 + : NSLocalizedString(@"Handle tapping on links on pages from this host in a non-standard way to avoid possibly opening external applications", nil)) 231 + ]; 232 + [section addFormRow:row]; 233 + [form addFormSection:section]; 234 + } 235 + 220 236 } 221 237 222 238 /* security section */
+18 -10
Endless/WebViewTab.m
··· 345 345 else if (![[url scheme] isEqualToString:@"endlessipc"]) { 346 346 /* try to prevent universal links from triggering by refusing the initial request and starting a new one */ 347 347 BOOL iframe = ![[[request URL] absoluteString] isEqualToString:[[request mainDocumentURL] absoluteString]]; 348 - if (iframe) { 348 + 349 + HostSettings *hs = [HostSettings settingsOrDefaultsForHost:[url host]]; 350 + if ([hs boolSettingOrDefault:HOST_SETTINGS_KEY_UNIVERSAL_LINK_PROTECTION]) { 351 + if (iframe && navigationType != UIWebViewNavigationTypeLinkClicked) { 349 352 #ifdef TRACE 350 - NSLog(@"[Tab %@] not doing universal link workaround for iframe %@", [self tabIndex], url); 353 + NSLog(@"[Tab %@] not doing universal link workaround for iframe %@", [self tabIndex], url); 351 354 #endif 352 - } else if (navigationType == UIWebViewNavigationTypeBackForward) { 355 + } else if (navigationType == UIWebViewNavigationTypeBackForward) { 353 356 #ifdef TRACE 354 - NSLog(@"[Tab %@] not doing universal link workaround for back/forward navigation to %@", [self tabIndex], url); 357 + NSLog(@"[Tab %@] not doing universal link workaround for back/forward navigation to %@", [self tabIndex], url); 355 358 #endif 356 - } else if ([[[url scheme] lowercaseString] hasPrefix:@"http"] && ![NSURLProtocol propertyForKey:UNIVERSAL_LINKS_WORKAROUND_KEY inRequest:request]) { 357 - NSMutableURLRequest *tr = [request mutableCopy]; 358 - [NSURLProtocol setProperty:@YES forKey:UNIVERSAL_LINKS_WORKAROUND_KEY inRequest:tr]; 359 + } else if ([[[url scheme] lowercaseString] hasPrefix:@"http"] && ![NSURLProtocol propertyForKey:UNIVERSAL_LINKS_WORKAROUND_KEY inRequest:request]) { 360 + NSMutableURLRequest *tr = [request mutableCopy]; 361 + [NSURLProtocol setProperty:@YES forKey:UNIVERSAL_LINKS_WORKAROUND_KEY inRequest:tr]; 359 362 #ifdef TRACE 360 - NSLog(@"[Tab %@] doing universal link workaround for %@", [self tabIndex], url); 363 + NSLog(@"[Tab %@] doing universal link workaround for %@", [self tabIndex], url); 361 364 #endif 362 - [self loadRequest:tr withForce:NO]; 363 - return NO; 365 + [self loadRequest:tr withForce:NO]; 366 + return NO; 367 + } 368 + } else { 369 + #ifdef TRACE 370 + NSLog(@"[Tab %@] not doing universal link workaround for %@ due to HostSettings", [self tabIndex], url); 371 + #endif 364 372 } 365 373 366 374 if (!iframe)