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.

[HTTPSEverywhere noteInsecureRedirectionForURL]: pass both URLs

The URL being redirected from may not have the rule apply, so pass
the URL being redirected to so it can also be checked.

Fixes redirection loop from https://planet.gnome.org/ to http://

Closes #56

+6 -8
+1 -1
Endless/HTTPSEverywhere.h
··· 19 19 + (NSArray *)potentiallyApplicableRulesForHost:(NSString *)host; 20 20 + (NSURL *)rewrittenURI:(NSURL *)URL withRules:(NSArray *)rules; 21 21 + (BOOL)needsSecureCookieFromHost:(NSString *)fromHost forHost:(NSString *)forHost cookieName:(NSString *)cookie; 22 - + (void)noteInsecureRedirectionForURL:(NSURL *)URL; 22 + + (void)noteInsecureRedirectionForURL:(NSURL *)URL toURL:(NSURL *)toURL; 23 23 + (BOOL)ruleNameIsDisabled:(NSString *)name; 24 24 + (void)enableRuleByName:(NSString *)name; 25 25 + (void)disableRuleByName:(NSString *)name withReason:(NSString *)reason;
+4 -6
Endless/HTTPSEverywhere.m
··· 194 194 return NO; 195 195 } 196 196 197 - + (void)noteInsecureRedirectionForURL:(NSURL *)URL 197 + + (void)noteInsecureRedirectionForURL:(NSURL *)URL toURL:(NSURL *)toURL 198 198 { 199 199 if (insecureRedirections == nil) { 200 200 insecureRedirections = [[NSMutableDictionary alloc] init]; 201 201 } 202 202 203 203 NSNumber *count = [insecureRedirections objectForKey:URL]; 204 - if (count != nil && [count intValue] != 0) { 204 + if (count != nil && [count intValue] != 0) 205 205 count = [NSNumber numberWithInt:[count intValue] + 1]; 206 - } 207 - else { 206 + else 208 207 count = [NSNumber numberWithInt:1]; 209 - } 210 208 211 209 [insecureRedirections setObject:count forKey:URL]; 212 210 ··· 215 213 } 216 214 217 215 for (HTTPSEverywhereRule *rule in [[self class] potentiallyApplicableRulesForHost:[URL host]]) { 218 - if ([rule apply:URL] != nil) { 216 + if ([rule apply:URL] != nil || [rule apply:toURL] != nil) { 219 217 NSLog(@"[HTTPSEverywhere] insecure redirection count %@ for %@, disabling rule %@", count, URL, [rule name]); 220 218 [[self class] disableRuleByName:[rule name] withReason:@"Redirection loop"]; 221 219 }
+1 -1
Endless/URLInterceptor.m
··· 551 551 552 552 /* if we're being redirected from secure back to insecure, we might be stuck in a loop from an HTTPSEverywhere rule */ 553 553 if ([[[[self actualRequest] URL] scheme] isEqualToString:@"https"] && [[[newRequest URL] scheme] isEqualToString:@"http"]) 554 - [HTTPSEverywhere noteInsecureRedirectionForURL:[[self actualRequest] URL]]; 554 + [HTTPSEverywhere noteInsecureRedirectionForURL:[[self actualRequest] URL] toURL:[newRequest URL]]; 555 555 556 556 /* process it all over again */ 557 557 [NSURLProtocol removePropertyForKey:REWRITTEN_KEY inRequest:newRequest];