Permalink
Browse files

fixed a sneaky bug where some pages load 'about:blank' into an iframe…

…, and then load ads into that iframe, so ClickToFlash was thinking that it was a local page and autoloading the ad. booooo
  • Loading branch information...
1 parent 056f38b commit ec2265a152b28b8edaee5518ca1101a2ae6a6eb5 Simone Manganelli committed Jul 25, 2009
Showing with 18 additions and 7 deletions.
  1. +6 −3 Plugin/CTFWhitelist.m
  2. +12 −4 Plugin/Plugin.m
View
@@ -152,9 +152,12 @@ - (void) _addToWhitelistAlertDidEnd: (NSAlert *)alert returnCode: (int)returnCod
- (BOOL) _isHostWhitelisted
{
- // Nil hosts whitelisted by default (e.g. Dashboard)
- if (![self host])
- {
+ if ( [[self baseURL] hasPrefix:@"about:"] ) {
+ // encountered an ad on addictinggames.com where it loaded an
+ // about:blank page and then inserted ads there
+ return NO;
+ } else if ( ![self host] ) {
+ // Nil hosts whitelisted by default (e.g. Dashboard)
return YES;
}
View
@@ -704,10 +704,18 @@ - (BOOL) validateMenuItem: (NSMenuItem *)menuItem
SEL action = [menuItem action];
if (action == @selector(addToWhitelist:))
{
- NSString* title = [NSString stringWithFormat:
- NSLocalizedString(@"Add %@ to Whitelist", @"Add <sitename> to Whitelist menu title"),
- [self host]];
- [menuItem setTitle: title];
+ if ([self host]) {
+ NSString* title = [NSString stringWithFormat:
+ NSLocalizedString(@"Add %@ to Whitelist", @"Add <sitename> to Whitelist menu title"),
+ [self host]];
+ [menuItem setTitle: title];
+ } else {
+ // this case happens sometimes if the base URL is "about:blank",
+ // so there's no base URL to use for the whitelist, so just disable
+ // the menu item
+ enabled = NO;
+ }
+
if ([self _isHostWhitelisted])
enabled = NO;
}

0 comments on commit ec2265a

Please sign in to comment.