[Webkit-unassigned] [Bug 37357] New: UserContentURLPattern matches a pattern of "http://ple.com/" for "http://apple.com/"

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Apr 9 13:39:49 PDT 2010


           Summary: UserContentURLPattern matches a pattern of
                    "http://ple.com/" for "http://apple.com/"
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: PC
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore Misc.
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: timothy at hatcher.name
                CC: hyatt at apple.com, aroben at apple.com

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
    // 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] == '.';

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list