From ec2265a152b28b8edaee5518ca1101a2ae6a6eb5 Mon Sep 17 00:00:00 2001 From: Simone Manganelli Date: Sat, 25 Jul 2009 13:24:49 -0700 Subject: [PATCH] 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 --- Plugin/CTFWhitelist.m | 9 ++++++--- Plugin/Plugin.m | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Plugin/CTFWhitelist.m b/Plugin/CTFWhitelist.m index b69b7a7b..d6029e96 100644 --- a/Plugin/CTFWhitelist.m +++ b/Plugin/CTFWhitelist.m @@ -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; } diff --git a/Plugin/Plugin.m b/Plugin/Plugin.m index c3b90c9f..89501030 100755 --- a/Plugin/Plugin.m +++ b/Plugin/Plugin.m @@ -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 to Whitelist menu title"), - [self host]]; - [menuItem setTitle: title]; + if ([self host]) { + NSString* title = [NSString stringWithFormat: + NSLocalizedString(@"Add %@ to Whitelist", @"Add 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; }