The matchesHost function matches domains when it shouldn't. bool UserContentURLPattern::matchesHost(const KURL& test) const { if (test.host() == m_host) return true; if (!m_matchSubdomains) return false; // If we're matching subdomains, and we have no host, that means the pattern // was <scheme>://*/<whatever>, so we match anything. if (!m_host.length()) return true; // Check if the test host is a subdomain of our host. return test.host().endsWith(m_host, false); } The error is in the last line. Consider test.host() is "apple.com" and m_host from the pattern is "ple.com", this will return true. We need to look for a period after it checks for the suffix. Something like: const String& host = test.host(); // Check if the domain is a subdomain of our host. if (!host.endsWith(m_host, false)) return false; ASSERT(host.length() > m_host.length()); // Check that the character before the suffix is a period. return host[host.length() - m_host.length() - 1] == '.';
Created attachment 53963 [details] Proposed change
Comment on attachment 53963 [details] Proposed change Is there any way to make tests for UserContentURLPattern? I don't like seeing a bug fix without a test. Can we rig things so this can be tested with DumpRenderTree? r=me
Landed in r57990. There is no testing harness for UserContentURLPattern yet. I filed bug 37931.