Changeset 116842 in webkit


Ignore:
Timestamp:
May 12, 2012 1:31:30 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Cleanup ContentSecurityPolicy naming conventions.
https://bugs.webkit.org/show_bug.cgi?id=86282

Patch by Mike West <mkwst@chromium.org> on 2012-05-12
Reviewed by Adam Barth.

Two tiny changes:

  1. reportURI and reportURL are both used within the CSP implementation. We should standardize on reportURI to match the spec.
  1. Renames ContentSecurityPolicy::allowConnectFromSource to ContentSecurityPolicy::allowConnectToSource for clarity.

No new tests, as there's no user-visible change.

  • Modules/websockets/WebSocket.cpp:

(WebCore::WebSocket::connect):

  • page/ContentSecurityPolicy.cpp:

(CSPDirectiveList):
(WebCore::CSPDirectiveList::reportViolation):
(WebCore::CSPDirectiveList::allowConnectToSource):
(WebCore::CSPDirectiveList::parseReportURI):
(WebCore::CSPDirectiveList::addDirective):
(WebCore::ContentSecurityPolicy::allowConnectToSource):

  • page/ContentSecurityPolicy.h:
  • page/EventSource.cpp:

(WebCore::EventSource::create):

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::open):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116840 r116842  
     12012-05-12  Mike West  <mkwst@chromium.org>
     2
     3        Cleanup ContentSecurityPolicy naming conventions.
     4        https://bugs.webkit.org/show_bug.cgi?id=86282
     5
     6        Reviewed by Adam Barth.
     7
     8        Two tiny changes:
     9       
     10        1. `reportURI` and `reportURL` are both used within the CSP
     11           implementation. We should standardize on `reportURI` to match the
     12           spec.
     13       
     14        2. Renames `ContentSecurityPolicy::allowConnectFromSource` to
     15           `ContentSecurityPolicy::allowConnectToSource` for clarity.
     16
     17        No new tests, as there's no user-visible change.
     18
     19        * Modules/websockets/WebSocket.cpp:
     20        (WebCore::WebSocket::connect):
     21        * page/ContentSecurityPolicy.cpp:
     22        (CSPDirectiveList):
     23        (WebCore::CSPDirectiveList::reportViolation):
     24        (WebCore::CSPDirectiveList::allowConnectToSource):
     25        (WebCore::CSPDirectiveList::parseReportURI):
     26        (WebCore::CSPDirectiveList::addDirective):
     27        (WebCore::ContentSecurityPolicy::allowConnectToSource):
     28        * page/ContentSecurityPolicy.h:
     29        * page/EventSource.cpp:
     30        (WebCore::EventSource::create):
     31        * xml/XMLHttpRequest.cpp:
     32        (WebCore::XMLHttpRequest::open):
     33
    1342012-05-11  Mark Pilgrim  <pilgrim@chromium.org>
    235
  • trunk/Source/WebCore/Modules/websockets/WebSocket.cpp

    r112499 r116842  
    222222    }
    223223
    224     if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectFromSource(m_url)) {
     224    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(m_url)) {
    225225        m_state = CLOSED;
    226226
  • trunk/Source/WebCore/page/ContentSecurityPolicy.cpp

    r116274 r116842  
    504504    bool allowFontFromSource(const KURL&) const;
    505505    bool allowMediaFromSource(const KURL&) const;
    506     bool allowConnectFromSource(const KURL&) const;
     506    bool allowConnectToSource(const KURL&) const;
    507507
    508508private:
     
    545545    OwnPtr<CSPDirective> m_connectSrc;
    546546
    547     Vector<KURL> m_reportURLs;
     547    Vector<KURL> m_reportURIs;
    548548};
    549549
     
    581581    m_scriptExecutionContext->addConsoleMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message);
    582582
    583     if (m_reportURLs.isEmpty())
     583    if (m_reportURIs.isEmpty())
    584584        return;
    585585
     
    619619    RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8());
    620620
    621     for (size_t i = 0; i < m_reportURLs.size(); ++i)
    622         PingLoader::reportContentSecurityPolicyViolation(frame, m_reportURLs[i], report);
     621    for (size_t i = 0; i < m_reportURIs.size(); ++i)
     622        PingLoader::reportContentSecurityPolicyViolation(frame, m_reportURIs[i], report);
    623623}
    624624
     
    739739}
    740740
    741 bool CSPDirectiveList::allowConnectFromSource(const KURL& url) const
     741bool CSPDirectiveList::allowConnectToSource(const KURL& url) const
    742742{
    743743    DEFINE_STATIC_LOCAL(String, type, ("connect"));
     
    827827        if (urlBegin < position) {
    828828            String url = String(urlBegin, position - urlBegin);
    829             m_reportURLs.append(m_scriptExecutionContext->completeURL(url));
     829            m_reportURIs.append(m_scriptExecutionContext->completeURL(url));
    830830        }
    831831    }
     
    880880    else if (!m_haveSandboxPolicy && equalIgnoringCase(name, sandbox))
    881881        applySandboxPolicy(value);
    882     else if (m_reportURLs.isEmpty() && equalIgnoringCase(name, reportURI))
     882    else if (m_reportURIs.isEmpty() && equalIgnoringCase(name, reportURI))
    883883        parseReportURI(value);
    884884    else
     
    10051005}
    10061006
    1007 bool ContentSecurityPolicy::allowConnectFromSource(const KURL& url) const
    1008 {
    1009     return isAllowedByAll<&CSPDirectiveList::allowConnectFromSource>(m_policies, url);
    1010 }
    1011 
    1012 }
     1007bool ContentSecurityPolicy::allowConnectToSource(const KURL& url) const
     1008{
     1009    return isAllowedByAll<&CSPDirectiveList::allowConnectToSource>(m_policies, url);
     1010}
     1011
     1012}
  • trunk/Source/WebCore/page/ContentSecurityPolicy.h

    r116254 r116842  
    7575    bool allowFontFromSource(const KURL&) const;
    7676    bool allowMediaFromSource(const KURL&) const;
    77     bool allowConnectFromSource(const KURL&) const;
     77    bool allowConnectToSource(const KURL&) const;
    7878
    7979    void setOverrideAllowInlineStyle(bool);
  • trunk/Source/WebCore/page/EventSource.cpp

    r107239 r116842  
    8989    }
    9090
    91     if (!context->contentSecurityPolicy()->allowConnectFromSource(fullURL)) {
     91    if (!context->contentSecurityPolicy()->allowConnectToSource(fullURL)) {
    9292        // FIXME: Should this be throwing an exception?
    9393        ec = SECURITY_ERR;
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r112555 r116842  
    479479    }
    480480
    481     if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectFromSource(url)) {
     481    if (!scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) {
    482482        // FIXME: Should this be throwing an exception?
    483483        ec = SECURITY_ERR;
Note: See TracChangeset for help on using the changeset viewer.