<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[45741] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/45741">45741</a></dd>
<dt>Author</dt> <dd>abarth@webkit.org</dd>
<dt>Date</dt> <dd>2009-07-10 18:31:48 -0700 (Fri, 10 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-07-10  Daniel Bates  &lt;dbates@intudata.com&gt;

        Reviewed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=27151
        
        Fixes issue where JavaScript URLs that contain null- and non-null control characters can
        bypass XSSAuditor.

        Tests: http/tests/security/xssAuditor/javascript-link-control-char.html
               http/tests/security/xssAuditor/javascript-link-null-char.html
               http/tests/security/xssAuditor/javascript-link.html

        * bindings/js/ScriptController.cpp:
        (WebCore::ScriptController::evaluate): Separated out logic for JavaScript URLs from 
        inline scripts. For JavaScript URLs, calls XSSAuditor::canEvaluateJavaScriptURL.
        * bindings/v8/ScriptController.cpp:
        (WebCore::ScriptController::evaluate): Made similar changes to evaluate() as in 
        bindings/js/ScriptController.cpp.
        * page/XSSAuditor.cpp:
        (WebCore::XSSAuditor::canEvaluateJavaScriptURL): Separated out logic for JavaScript URLs
        into its own method.
        * page/XSSAuditor.h:

2009-07-10  Daniel Bates  &lt;dbates@intudata.com&gt;

        Reviewed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=27151

        Tests prevention of JavaScript URLs that contain null- and non-null control characters.

        * http/tests/security/xssAuditor/javascript-link-control-char-expected.txt: Added.
        * http/tests/security/xssAuditor/javascript-link-control-char.html: Added.
        * http/tests/security/xssAuditor/javascript-link-expected.txt: Added.
        * http/tests/security/xssAuditor/javascript-link-null-char-expected.txt: Added.
        * http/tests/security/xssAuditor/javascript-link-null-char.html: Added.
        * http/tests/security/xssAuditor/javascript-link.html: Added.
        * http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorebindingsjsScriptControllercpp">trunk/WebCore/bindings/js/ScriptController.cpp</a></li>
<li><a href="#trunkWebCorebindingsv8ScriptControllercpp">trunk/WebCore/bindings/v8/ScriptController.cpp</a></li>
<li><a href="#trunkWebCorepageXSSAuditorcpp">trunk/WebCore/page/XSSAuditor.cpp</a></li>
<li><a href="#trunkWebCorepageXSSAuditorh">trunk/WebCore/page/XSSAuditor.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkcontrolcharexpectedtxt">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkcontrolcharhtml">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkexpectedtxt">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinknullcharexpectedtxt">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinknullcharhtml">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkhtml">trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityxssAuditorresourcesechointertagclickandnotifypl">trunk/LayoutTests/http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/LayoutTests/ChangeLog        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2009-07-10  Daniel Bates  &lt;dbates@intudata.com&gt;
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27151
+
+        Tests prevention of JavaScript URLs that contain null- and non-null control characters.
+
+        * http/tests/security/xssAuditor/javascript-link-control-char-expected.txt: Added.
+        * http/tests/security/xssAuditor/javascript-link-control-char.html: Added.
+        * http/tests/security/xssAuditor/javascript-link-expected.txt: Added.
+        * http/tests/security/xssAuditor/javascript-link-null-char-expected.txt: Added.
+        * http/tests/security/xssAuditor/javascript-link-null-char.html: Added.
+        * http/tests/security/xssAuditor/javascript-link.html: Added.
+        * http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl: Added.
+
</ins><span class="cx"> 2009-07-10  Michelangelo De Simone  &lt;micdesim@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adele Peterson.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkcontrolcharexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char-expected.txt (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char-expected.txt        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkcontrolcharhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char.html (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-control-char.html        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.setXSSAuditorEnabled(true);
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;iframe src='http://localhost:8000/security/xssAuditor/resources/echo-intertag-click-and-notify.pl?elmid=anchorLink&amp;q=%3Ca+id%3DanchorLink+href%3Djavascript%3Aalert%28/XSS%05/%29%3Etest%3C/a%3E'&gt;
+&lt;/iframe&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-expected.txt (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-expected.txt        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinknullcharexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char-expected.txt (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char-expected.txt        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+CONSOLE MESSAGE: line 1: Refused to execute a JavaScript script. Source code of script found within request.
+
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinknullcharhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char.html (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link-null-char.html        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.setXSSAuditorEnabled(true);
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;iframe src='http://localhost:8000/security/xssAuditor/resources/echo-intertag-click-and-notify.pl?elmid=anchorLink&amp;q=%3Ca+id%3DanchorLink+href%3Djavascript%3Aal%00ert%28/XSS/%29%3Etest%3C/a%3E'&gt;
+&lt;/iframe&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorjavascriptlinkhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link.html (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/javascript-link.html        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.setXSSAuditorEnabled(true);
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;iframe src='http://localhost:8000/security/xssAuditor/resources/echo-intertag-click-and-notify.pl?elmid=anchorLink&amp;q=%3Ca+id%3DanchorLink+href%3Djavascript%3Aalert%28/XSS/%29%3Etest%3C/a%3E'&gt;
+&lt;/iframe&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityxssAuditorresourcesechointertagclickandnotifypl"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl (0 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl                                (rev 0)
+++ trunk/LayoutTests/http/tests/security/xssAuditor/resources/echo-intertag-click-and-notify.pl        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -0,0 +1,28 @@
</span><ins>+#!/usr/bin/perl -wT
+use strict;
+use CGI;
+
+my $cgi = new CGI;
+
+print &quot;Content-Type: text/html; charset=UTF-8\n\n&quot;;
+
+print &quot;&lt;!DOCTYPE html&gt;\n&quot;;
+print &quot;&lt;html&gt;\n&quot;;
+print &quot;&lt;head&gt;\n&quot;;
+print &quot;&lt;script&gt;\n&quot;;
+print &quot;window.onload = function()\n&quot;;
+print &quot;{\n&quot;;
+print &quot;    var event = document.createEvent('MouseEvent');\n&quot;;
+print &quot;    event.initEvent('click', true, true);\n&quot;;
+print &quot;    document.getElementById('&quot;.$cgi-&gt;param('elmid').&quot;').dispatchEvent(event);\n&quot;;
+print &quot;}\n&quot;;
+print &quot;&lt;/script&gt;\n&quot;;
+print &quot;&lt;/head&gt;\n&quot;;
+print &quot;&lt;body&gt;\n&quot;;
+print $cgi-&gt;param('q');
+print &quot;&lt;script&gt;\n&quot;;
+print &quot;if (window.layoutTestController)\n&quot;;
+print &quot;    layoutTestController.notifyDone();\n&quot;;
+print &quot;&lt;/script&gt;\n&quot;;
+print &quot;&lt;/body&gt;\n&quot;;
+print &quot;&lt;/html&gt;\n&quot;;
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/WebCore/ChangeLog        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2009-07-10  Daniel Bates  &lt;dbates@intudata.com&gt;
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=27151
+        
+        Fixes issue where JavaScript URLs that contain null- and non-null control characters can
+        bypass XSSAuditor.
+
+        Tests: http/tests/security/xssAuditor/javascript-link-control-char.html
+               http/tests/security/xssAuditor/javascript-link-null-char.html
+               http/tests/security/xssAuditor/javascript-link.html
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::evaluate): Separated out logic for JavaScript URLs from 
+        inline scripts. For JavaScript URLs, calls XSSAuditor::canEvaluateJavaScriptURL.
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::evaluate): Made similar changes to evaluate() as in 
+        bindings/js/ScriptController.cpp.
+        * page/XSSAuditor.cpp:
+        (WebCore::XSSAuditor::canEvaluateJavaScriptURL): Separated out logic for JavaScript URLs
+        into its own method.
+        * page/XSSAuditor.h:
+
</ins><span class="cx"> 2009-07-10  Michelangelo De Simone  &lt;micdesim@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Adele Peterson.
</span></span></pre></div>
<a id="trunkWebCorebindingsjsScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/js/ScriptController.cpp (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/js/ScriptController.cpp        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/WebCore/bindings/js/ScriptController.cpp        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -81,7 +81,15 @@
</span><span class="cx"> 
</span><span class="cx"> ScriptValue ScriptController::evaluate(const ScriptSourceCode&amp; sourceCode) 
</span><span class="cx"> {
</span><del>-    if (!m_XSSAuditor-&gt;canEvaluate(sourceCode.source())) {
</del><ins>+    const SourceCode&amp; jsSourceCode = sourceCode.jsSourceCode();
+    String sourceURL = jsSourceCode.provider()-&gt;url();
+    
+    if (sourceURL.isNull() &amp;&amp; !m_XSSAuditor-&gt;canEvaluateJavaScriptURL(sourceCode.source())) {
+        // This JavaScript URL is not safe to be evaluated.
+        return JSValue();
+    }
+    
+    if (!sourceURL.isNull() &amp;&amp; !m_XSSAuditor-&gt;canEvaluate(sourceCode.source())) {
</ins><span class="cx">         // This script is not safe to be evaluated.
</span><span class="cx">         return JSValue();
</span><span class="cx">     }
</span><span class="lines">@@ -89,8 +97,6 @@
</span><span class="cx">     // evaluate code. Returns the JS return value or 0
</span><span class="cx">     // if there was none, an error occured or the type couldn't be converted.
</span><span class="cx"> 
</span><del>-    const SourceCode&amp; jsSourceCode = sourceCode.jsSourceCode();
-
</del><span class="cx">     initScriptIfNeeded();
</span><span class="cx">     // inlineCode is true for &lt;a href=&quot;javascript:doSomething()&quot;&gt;
</span><span class="cx">     // and false for &lt;script&gt;doSomething()&lt;/script&gt;. Check if it has the
</span><span class="lines">@@ -98,7 +104,6 @@
</span><span class="cx">     // See smart window.open policy for where this is used.
</span><span class="cx">     ExecState* exec = m_windowShell-&gt;window()-&gt;globalExec();
</span><span class="cx">     const String* savedSourceURL = m_sourceURL;
</span><del>-    String sourceURL = jsSourceCode.provider()-&gt;url();
</del><span class="cx">     m_sourceURL = &amp;sourceURL;
</span><span class="cx"> 
</span><span class="cx">     JSLock lock(false);
</span></span></pre></div>
<a id="trunkWebCorebindingsv8ScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/bindings/v8/ScriptController.cpp (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/bindings/v8/ScriptController.cpp        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/WebCore/bindings/v8/ScriptController.cpp        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -193,7 +193,14 @@
</span><span class="cx"> // Evaluate a script file in the environment of this proxy.
</span><span class="cx"> ScriptValue ScriptController::evaluate(const ScriptSourceCode&amp; sourceCode)
</span><span class="cx"> {
</span><del>-    if (!m_XSSAuditor-&gt;canEvaluate(sourceCode.source())) {
</del><ins>+    String sourceURL = sourceCode.jsSourceCode().provider()-&gt;url();
+    
+    if (sourceURL.isNull() &amp;&amp; !m_XSSAuditor-&gt;canEvaluateJavaScriptURL(sourceCode.source())) {
+        // This JavaScript URL is not safe to be evaluated.
+        return JSValue();
+    }
+    
+    if (!sourceURL.isNull() &amp;&amp; !m_XSSAuditor-&gt;canEvaluate(sourceCode.source())) {
</ins><span class="cx">         // This script is not safe to be evaluated.
</span><span class="cx">         return ScriptValue();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkWebCorepageXSSAuditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/page/XSSAuditor.cpp (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/page/XSSAuditor.cpp        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/WebCore/page/XSSAuditor.cpp        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -77,6 +77,19 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool XSSAuditor::canEvaluateJavaScriptURL(const String&amp; code) const
+{
+    if (!isEnabled())
+        return true;
+
+    if (findInRequest(code, false, false)) {
+        DEFINE_STATIC_LOCAL(String, consoleMessage, (&quot;Refused to execute a JavaScript script. Source code of script found within request.\n&quot;));
+        m_frame-&gt;domWindow()-&gt;console()-&gt;addMessage(JSMessageSource, ErrorMessageLevel, consoleMessage, 1, String());
+        return false;
+    }
+    return true;
+}
+
</ins><span class="cx"> bool XSSAuditor::canCreateInlineEventListener(const String&amp;, const String&amp; code) const
</span><span class="cx"> {
</span><span class="cx">     if (!isEnabled())
</span></span></pre></div>
<a id="trunkWebCorepageXSSAuditorh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/page/XSSAuditor.h (45740 => 45741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/page/XSSAuditor.h        2009-07-11 01:21:45 UTC (rev 45740)
+++ trunk/WebCore/page/XSSAuditor.h        2009-07-11 01:31:48 UTC (rev 45741)
</span><span class="lines">@@ -74,6 +74,10 @@
</span><span class="cx">         // based on the content of any user-submitted data.
</span><span class="cx">         bool canEvaluate(const String&amp; sourceCode) const;
</span><span class="cx"> 
</span><ins>+        // Determines whether the JavaScript URL should be allowed or denied execution
+        // based on the content of any user-submitted data.
+        bool canEvaluateJavaScriptURL(const String&amp; code) const;
+
</ins><span class="cx">         // Determines whether the event listener should be created based on the
</span><span class="cx">         // content of any user-submitted data.
</span><span class="cx">         bool canCreateInlineEventListener(const String&amp; functionName, const String&amp; code) const;
</span></span></pre>
</div>
</div>

</body>
</html>