Changeset 140839 in webkit


Ignore:
Timestamp:
Jan 25, 2013 9:48:54 AM (11 years ago)
Author:
mkwst@chromium.org
Message:

Source/WebCore: ScriptController::executeIfJavaScriptURL incorrectly checks viewsource mode.
incorrectly blocks execution based on the frame's viewsource state.
https://bugs.webkit.org/show_bug.cgi?id=101683

Reviewed by Adam Barth.

ScriptController::executeIfJavaScriptURL currently checks whether the
frame in which a 'javascript:' URL might be executed is in viewsource
mode. This incorrectly handles the case where the viewsource attribute
is added after a document loads: the _frame_ is in viewsource mode, the
_document_ is not. The latter should control execution, not the former.

This patch drops the inViewSourceMode check from executeIfJavaScriptURL
entirely, as the document's viewsource state is checked in
canExecuteScripts, which is already called when the 'javascript:' URL is
passed to executeScript. The checks should remain centralized there.

Test: http/tests/security/view-source-javascript-url-in-document.html

  • bindings/ScriptControllerBase.cpp:

(WebCore::ScriptController::executeIfJavaScriptURL):

Drop the incorrect check against the Frame's viewsource mode. The
correct check against the Document's viewsource mode is performed
in canExecuteScripts (which is called via executeScript).

LayoutTests: Merge isViewSource checks in ScriptController::executeIfJavaScriptURL and ScriptController::canExecuteScripts.
https://bugs.webkit.org/show_bug.cgi?id=101683

Reviewed by Adam Barth.

  • http/tests/security/view-source-javascript-url-in-document-expected.txt: Added.
  • http/tests/security/view-source-javascript-url-in-document.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140838 r140839  
     12013-01-25  Mike West  <mkwst@chromium.org>
     2
     3        Merge isViewSource checks in ScriptController::executeIfJavaScriptURL and ScriptController::canExecuteScripts.
     4        https://bugs.webkit.org/show_bug.cgi?id=101683
     5
     6        Reviewed by Adam Barth.
     7
     8        * http/tests/security/view-source-javascript-url-in-document-expected.txt: Added.
     9        * http/tests/security/view-source-javascript-url-in-document.html: Added.
     10
    1112013-01-25  Erik Arvidsson  <arv@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r140836 r140839  
     12013-01-25  Mike West  <mkwst@chromium.org>
     2
     3        ScriptController::executeIfJavaScriptURL incorrectly checks viewsource mode.
     4        incorrectly blocks execution based on the frame's viewsource state.
     5        https://bugs.webkit.org/show_bug.cgi?id=101683
     6
     7        Reviewed by Adam Barth.
     8
     9        ScriptController::executeIfJavaScriptURL currently checks whether the
     10        frame in which a 'javascript:' URL might be executed is in viewsource
     11        mode. This incorrectly handles the case where the viewsource attribute
     12        is added after a document loads: the _frame_ is in viewsource mode, the
     13        _document_ is not. The latter should control execution, not the former.
     14
     15        This patch drops the inViewSourceMode check from executeIfJavaScriptURL
     16        entirely, as the document's viewsource state is checked in
     17        canExecuteScripts, which is already called when the 'javascript:' URL is
     18        passed to executeScript. The checks should remain centralized there.
     19
     20        Test: http/tests/security/view-source-javascript-url-in-document.html
     21
     22        * bindings/ScriptControllerBase.cpp:
     23        (WebCore::ScriptController::executeIfJavaScriptURL):
     24            Drop the incorrect check against the Frame's viewsource mode. The
     25            correct check against the Document's viewsource mode is performed
     26            in canExecuteScripts (which is called via executeScript).
     27
    1282013-01-25  Gustavo Noronha Silva  <gns@gnome.org>
    229
  • trunk/Source/WebCore/bindings/ScriptControllerBase.cpp

    r137318 r140839  
    8080
    8181    if (!m_frame->page()
    82         || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line)
    83         || m_frame->inViewSourceMode())
     82        || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_frame->document()->url(), eventHandlerPosition().m_line))
    8483        return true;
    8584
Note: See TracChangeset for help on using the changeset viewer.