⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 97270 in webkit


Ignore:
Timestamp:
Oct 12, 2011, 10:05:41 AM (15 years ago)
Author:
abarth@webkit.org
Message:

ScriptController::executeIfJavaScriptURL gets confused by synchronous frame loads
https://bugs.webkit.org/show_bug.cgi?id=69777

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

Source/WebCore:

Test: http/tests/security/xss-DENIED-synchronous-frame-load-in-javascript-url.html

  • bindings/ScriptControllerBase.cpp:

(WebCore::ScriptController::executeIfJavaScriptURL):

  • loader/DocumentWriter.cpp:

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

  • loader/DocumentWriter.h:

Source/WebKit/chromium:

  • src/WebFrameImpl.cpp:

(WebKit::WebFrameImpl::loadJavaScriptURL):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r97267 r97270  
     12011-10-12  Sergey Glazunov  <serg.glazunov@gmail.com>
     2
     3        ScriptController::executeIfJavaScriptURL gets confused by synchronous frame loads
     4        https://bugs.webkit.org/show_bug.cgi?id=69777
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: http/tests/security/xss-DENIED-synchronous-frame-load-in-javascript-url.html
     9
     10        * bindings/ScriptControllerBase.cpp:
     11        (WebCore::ScriptController::executeIfJavaScriptURL):
     12        * loader/DocumentWriter.cpp:
     13        (WebCore::DocumentWriter::replaceDocument):
     14        (WebCore::DocumentWriter::begin):
     15        * loader/DocumentWriter.h:
     16
    1172011-10-12  Vsevolod Vlasov  <vsevik@chromium.org>
    218
  • trunk/Source/WebCore/bindings/ScriptControllerBase.cpp

    r97110 r97270  
    9494    // destroy the frame.
    9595    RefPtr<Frame> protector(m_frame);
     96    RefPtr<Document> ownerDocument(m_frame->document());
    9697
    9798    const int javascriptSchemeLength = sizeof("javascript:") - 1;
     
    126127        // so protect it with a RefPtr.
    127128        if (RefPtr<DocumentLoader> loader = m_frame->document()->loader())
    128             loader->writer()->replaceDocument(scriptResult);
     129            loader->writer()->replaceDocument(scriptResult, ownerDocument.get());
    129130    }
    130131    return true;
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r97110 r97270  
    6565// and always contains the result of evaluating a javascript: url.
    6666// This is the <iframe src="javascript:'html'"> case.
    67 void DocumentWriter::replaceDocument(const String& source)
     67void DocumentWriter::replaceDocument(const String& source, Document* ownerDocument)
    6868{
    6969    m_frame->loader()->stopAllLoaders();
    70     begin(m_frame->document()->url(), true, InheritSecurityOrigin);
     70    begin(m_frame->document()->url(), true, ownerDocument);
    7171
    7272    if (!source.isNull()) {
     
    107107}
    108108
    109 void DocumentWriter::begin(const KURL& urlReference, bool dispatch, SecurityOriginSource originSource)
    110 {
    111     RefPtr<Document> oldDocument = m_frame->document();
    112 
     109void DocumentWriter::begin(const KURL& urlReference, bool dispatch, Document* ownerDocument)
     110{
    113111    // We grab a local copy of the URL because it's easy for callers to supply
    114112    // a URL that will be deallocated during the execution of this function.
     
    138136    if (m_decoder)
    139137        document->setDecoder(m_decoder.get());
    140     if (originSource == InheritSecurityOrigin) {
    141         document->setCookieURL(oldDocument->cookieURL());
    142         document->setSecurityOrigin(oldDocument->securityOrigin());
     138    if (ownerDocument) {
     139        document->setCookieURL(ownerDocument->cookieURL());
     140        document->setSecurityOrigin(ownerDocument->securityOrigin());
    143141    }
    144142
  • trunk/Source/WebCore/loader/DocumentWriter.h

    r97110 r97270  
    4848    // This is only called by ScriptController::executeIfJavaScriptURL
    4949    // and always contains the result of evaluating a javascript: url.
    50     void replaceDocument(const String&);
    51 
    52     enum SecurityOriginSource { CreateNewSecurityOrigin, InheritSecurityOrigin };
     50    void replaceDocument(const String&, Document* ownerDocument);
    5351
    5452    void begin();
    55     void begin(const KURL&, bool dispatchWindowObjectAvailable = true, SecurityOriginSource = CreateNewSecurityOrigin);
     53    void begin(const KURL&, bool dispatchWindowObjectAvailable = true, Document* ownerDocument = 0);
    5654    void addData(const char* bytes, size_t length);
    5755    void end();
  • trunk/Source/WebKit/chromium/ChangeLog

    r97266 r97270  
     12011-10-12  Sergey Glazunov  <serg.glazunov@gmail.com>
     2
     3        ScriptController::executeIfJavaScriptURL gets confused by synchronous frame loads
     4        https://bugs.webkit.org/show_bug.cgi?id=69777
     5
     6        Reviewed by Adam Barth.
     7
     8        * src/WebFrameImpl.cpp:
     9        (WebKit::WebFrameImpl::loadJavaScriptURL):
     10
    1112011-10-12  Yury Semikhatsky  <yurys@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp

    r97257 r97270  
    22742274        return;
    22752275
     2276    RefPtr<Document> ownerDocument(m_frame->document());
     2277
    22762278    // Protect privileged pages against bookmarklets and other javascript manipulations.
    22772279    if (SchemeRegistry::shouldTreatURLSchemeAsNotAllowingJavascriptURLs(m_frame->document()->url().protocol()))
     
    22862288
    22872289    if (!m_frame->navigationScheduler()->locationChangePending())
    2288         m_frame->document()->loader()->writer()->replaceDocument(scriptResult);
     2290        m_frame->document()->loader()->writer()->replaceDocument(scriptResult, ownerDocument.get());
    22892291}
    22902292
Note: See TracChangeset for help on using the changeset viewer.