RESOLVED FIXED Bug 37357
UserContentURLPattern matches a pattern of "http://ple.com/" for "http://apple.com/"
https://bugs.webkit.org/show_bug.cgi?id=37357
Summary UserContentURLPattern matches a pattern of "http://ple.com/" for "http://appl...
Timothy Hatcher
Reported 2010-04-09 13:39:49 PDT
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] == '.';
Attachments
Proposed change (4.57 KB, patch)
2010-04-21 09:25 PDT, Timothy Hatcher
darin: review+
timothy: commit-queue-
Timothy Hatcher
Comment 1 2010-04-21 09:25:59 PDT
Created attachment 53963 [details] Proposed change
Darin Adler
Comment 2 2010-04-21 09:28:41 PDT
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
Timothy Hatcher
Comment 3 2010-04-21 09:42:23 PDT
Landed in r57990. There is no testing harness for UserContentURLPattern yet. I filed bug 37931.
Note You need to log in before you can comment on or make changes to this bug.