Changeset 96260 in webkit


Ignore:
Timestamp:
Sep 28, 2011 2:01:37 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

JavaScript generated documents don't inherit the cookie URL
https://bugs.webkit.org/show_bug.cgi?id=69003

Patch by Sergey Glazunov <serg.glazunov@gmail.com> on 2011-09-28
Reviewed by Adam Barth.

Source/WebCore:

Test: http/tests/security/cookies/cookie-theft-with-javascript-doc.html

  • dom/Document.h:

(WebCore::Document::setCookieURL):

  • loader/DocumentWriter.cpp:

(WebCore::DocumentWriter::replaceDocument):
(WebCore::DocumentWriter::begin):

  • loader/DocumentWriter.h:

LayoutTests:

  • http/tests/security/cookies/cookie-theft-with-javascript-doc-expected.txt: Added.
  • http/tests/security/cookies/cookie-theft-with-javascript-doc.html: Added.
  • http/tests/security/cookies/resources/innocent-victim-with-cookies.html: Added.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96258 r96260  
     12011-09-28  Sergey Glazunov  <serg.glazunov@gmail.com>
     2
     3        JavaScript generated documents don't inherit the cookie URL
     4        https://bugs.webkit.org/show_bug.cgi?id=69003
     5
     6        Reviewed by Adam Barth.
     7
     8        * http/tests/security/cookies/cookie-theft-with-javascript-doc-expected.txt: Added.
     9        * http/tests/security/cookies/cookie-theft-with-javascript-doc.html: Added.
     10        * http/tests/security/cookies/resources/innocent-victim-with-cookies.html: Added.
     11
    1122011-09-28  Dimitri Glazkov  <dglazkov@chromium.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r96258 r96260  
     12011-09-28  Sergey Glazunov  <serg.glazunov@gmail.com>
     2
     3        JavaScript generated documents don't inherit the cookie URL
     4        https://bugs.webkit.org/show_bug.cgi?id=69003
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: http/tests/security/cookies/cookie-theft-with-javascript-doc.html
     9
     10        * dom/Document.h:
     11        (WebCore::Document::setCookieURL):
     12        * loader/DocumentWriter.cpp:
     13        (WebCore::DocumentWriter::replaceDocument):
     14        (WebCore::DocumentWriter::begin):
     15        * loader/DocumentWriter.h:
     16
    1172011-09-27  Dimitri Glazkov  <dglazkov@chromium.org>
    218
  • trunk/Source/WebCore/dom/Document.h

    r95593 r96260  
    824824    //
    825825    const KURL& cookieURL() const { return m_cookieURL; }
     826    void setCookieURL(const KURL& url) { m_cookieURL = url; }
    826827
    827828    // The firstPartyForCookies is used to compute whether this document
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r95901 r96260  
    6868{
    6969    m_frame->loader()->stopAllLoaders();
    70     begin(m_frame->document()->url(), true, m_frame->document()->securityOrigin());
     70    begin(m_frame->document()->url(), true, InheritSecurityOrigin);
    7171
    7272    if (!source.isNull()) {
     
    107107}
    108108
    109 void DocumentWriter::begin(const KURL& urlReference, bool dispatch, SecurityOrigin* origin)
    110 {
    111     // We need to take a reference to the security origin because |clear|
    112     // might destroy the document that owns it.
    113     RefPtr<SecurityOrigin> forcedSecurityOrigin = origin;
     109void DocumentWriter::begin(const KURL& urlReference, bool dispatch, SecurityOriginSource originSource)
     110{
     111    RefPtr<Document> oldDocument = m_frame->document();
    114112
    115113    // We grab a local copy of the URL because it's easy for callers to supply
     
    140138    if (m_decoder)
    141139        document->setDecoder(m_decoder.get());
    142     if (forcedSecurityOrigin)
    143         document->setSecurityOrigin(forcedSecurityOrigin.get());
     140    if (originSource == InheritSecurityOrigin) {
     141        document->setCookieURL(oldDocument->cookieURL());
     142        document->setSecurityOrigin(oldDocument->securityOrigin());
     143    }
    144144
    145145    m_frame->domWindow()->setURL(document->url());
  • trunk/Source/WebCore/loader/DocumentWriter.h

    r95901 r96260  
    5050    void replaceDocument(const String&);
    5151
     52    enum SecurityOriginSource { CreateNewSecurityOrigin, InheritSecurityOrigin };
     53
    5254    void begin();
    53     void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOrigin* forcedSecurityOrigin = 0);
     55    void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOriginSource = CreateNewSecurityOrigin);
    5456    void addData(const char* bytes, size_t length);
    5557    void end();
Note: See TracChangeset for help on using the changeset viewer.