The matchesHost function matches domains when it shouldn't.
bool UserContentURLPattern::matchesHost(const KURL& test) const
if (test.host() == m_host)
// If we're matching subdomains, and we have no host, that means the pattern
// was <scheme>://*/<whatever>, so we match anything.
// 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.
const String& host = test.host();
// Check if the domain is a subdomain of our host.
if (!host.endsWith(m_host, 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]
Comment on attachment 53963 [details]
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?
Landed in r57990.
There is no testing harness for UserContentURLPattern yet. I filed bug 37931.