Title: [124520] trunk
Revision
124520
Author
[email protected]
Date
2012-08-02 16:02:30 -0700 (Thu, 02 Aug 2012)

Log Message

scripts in formaction should be stripped upon paste
https://bugs.webkit.org/show_bug.cgi?id=92298

Reviewed by Eric Seidel.

Source/WebCore:

Strip formaction attribute values when the URL is of _javascript_ protocol.

Test: editing/pasteboard/paste-noscript-xhtml.html
      editing/pasteboard/paste-noscript.html

* dom/Element.cpp:
(WebCore::isAttributeToRemove): Explicitly compare with href and nohref instead of comparing
the ends of strings since comparing two AtomicString is much faster.

LayoutTests:

Added formaction attributes to tests.

* editing/pasteboard/paste-noscript-expected.txt:
* editing/pasteboard/paste-noscript-xhtml-expected.txt:
* editing/pasteboard/paste-noscript.html:
* editing/pasteboard/resources/paste-noscript-content.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124519 => 124520)


--- trunk/LayoutTests/ChangeLog	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/LayoutTests/ChangeLog	2012-08-02 23:02:30 UTC (rev 124520)
@@ -1,3 +1,17 @@
+2012-08-02  Ryosuke Niwa  <[email protected]>
+
+        scripts in formaction should be stripped upon paste
+        https://bugs.webkit.org/show_bug.cgi?id=92298
+
+        Reviewed by Eric Seidel.
+
+        Added formaction attributes to tests.
+
+        * editing/pasteboard/paste-noscript-expected.txt:
+        * editing/pasteboard/paste-noscript-xhtml-expected.txt:
+        * editing/pasteboard/paste-noscript.html:
+        * editing/pasteboard/resources/paste-noscript-content.html:
+
 2012-08-02  Elliott Sprehn  <[email protected]>
 
         Built in quotes don't use lang attribute

Modified: trunk/LayoutTests/editing/pasteboard/paste-noscript-expected.txt (124519 => 124520)


--- trunk/LayoutTests/editing/pasteboard/paste-noscript-expected.txt	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/LayoutTests/editing/pasteboard/paste-noscript-expected.txt	2012-08-02 23:02:30 UTC (rev 124520)
@@ -15,5 +15,5 @@
 <a id="anchor2" href=""
 <iframe id="iframe1" src="" x = 1;" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
 <iframe id="iframe1" src="" style="width: 200px; height: 100px; background-color: rgb(204, 238, 238); "></iframe>
-<form id="form1" action="" style="width: 200px; height: 150px; background-color:#cee;">This is a form<br><img src=""
-<form id="form1" action="" style="width: 200px; height: 150px; background-color: rgb(204, 238, 238); ">This is a form<br><img src=""
+<form id="form1" action="" formaction="_javascript_:sayHello()" style="width: 200px; height: 150px; background-color:#cee;">This is a form<br><img src=""
+<form id="form1" action="" formaction="" style="width: 200px; height: 150px; background-color: rgb(204, 238, 238); ">This is a form<br><img src=""

Modified: trunk/LayoutTests/editing/pasteboard/paste-noscript-xhtml-expected.txt (124519 => 124520)


--- trunk/LayoutTests/editing/pasteboard/paste-noscript-xhtml-expected.txt	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/LayoutTests/editing/pasteboard/paste-noscript-xhtml-expected.txt	2012-08-02 23:02:30 UTC (rev 124520)
@@ -42,6 +42,7 @@
 "
 | <form>
 |   action=""
+|   formaction="_javascript_:sayHello()"
 |   id="form1"
 |   style="width: 200px; height: 150px; background-color:#cee;"
 |   "This is a form<#selection-focus>"
@@ -72,6 +73,7 @@
 |   style="width: 200px; height: 100px; background-color: rgb(204, 238, 238); "
 | <form>
 |   action=""
+|   formaction=""
 |   id="form1"
 |   style="width: 200px; height: 150px; background-color: rgb(204, 238, 238); "
 |   "This is a form<#selection-caret>"

Modified: trunk/LayoutTests/editing/pasteboard/paste-noscript.html (124519 => 124520)


--- trunk/LayoutTests/editing/pasteboard/paste-noscript.html	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/LayoutTests/editing/pasteboard/paste-noscript.html	2012-08-02 23:02:30 UTC (rev 124520)
@@ -16,7 +16,7 @@
 <a id="anchor1" href=""
 <a id="anchor2" href=""
 <iframe id="iframe1" src="" x = 1;" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
-<form id="form1" action="" style="width: 200px; height: 150px; background-color:#cee;">This is a form<br><img src=""
+<form id="form1" action="" formaction="_javascript_:sayHello()" style="width: 200px; height: 150px; background-color:#cee;">This is a form<br><img src=""
 </div>
 <div id="pastehere" contenteditable="true">
 </div>

Modified: trunk/LayoutTests/editing/pasteboard/resources/paste-noscript-content.html (124519 => 124520)


--- trunk/LayoutTests/editing/pasteboard/resources/paste-noscript-content.html	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/LayoutTests/editing/pasteboard/resources/paste-noscript-content.html	2012-08-02 23:02:30 UTC (rev 124520)
@@ -11,5 +11,5 @@
 <script style="display: block; position: fixed; top: 4000px">alert('hello');</script>
 <script src="" style="display: block; position: fixed; top: 4000px"></script>
 <iframe id="iframe1" src="" style="width: 200px; height: 100px; background-color:#cee;"></iframe>
-<form id="form1" action="" style="width: 200px; height: 150px; background-color:#cee;">This is a form</form>
+<form id="form1" action="" formaction="_javascript_:sayHello()" style="width: 200px; height: 150px; background-color:#cee;">This is a form</form>
 </body>

Modified: trunk/Source/WebCore/ChangeLog (124519 => 124520)


--- trunk/Source/WebCore/ChangeLog	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/Source/WebCore/ChangeLog	2012-08-02 23:02:30 UTC (rev 124520)
@@ -1,3 +1,19 @@
+2012-08-02  Ryosuke Niwa  <[email protected]>
+
+        scripts in formaction should be stripped upon paste
+        https://bugs.webkit.org/show_bug.cgi?id=92298
+
+        Reviewed by Eric Seidel.
+
+        Strip formaction attribute values when the URL is of _javascript_ protocol.
+
+        Test: editing/pasteboard/paste-noscript-xhtml.html
+              editing/pasteboard/paste-noscript.html
+
+        * dom/Element.cpp:
+        (WebCore::isAttributeToRemove): Explicitly compare with href and nohref instead of comparing
+        the ends of strings since comparing two AtomicString is much faster.
+
 2012-08-02  Elliott Sprehn  <[email protected]>
 
         Built in quotes don't use lang attribute

Modified: trunk/Source/WebCore/dom/Element.cpp (124519 => 124520)


--- trunk/Source/WebCore/dom/Element.cpp	2012-08-02 23:01:06 UTC (rev 124519)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-08-02 23:02:30 UTC (rev 124520)
@@ -760,9 +760,11 @@
     return name.namespaceURI().isNull() && name.localName().startsWith("on");
 }
 
+// FIXME: Share code with Element::isURLAttribute.
 static bool isAttributeToRemove(const QualifiedName& name, const AtomicString& value)
-{    
-    return (name.localName().endsWith(hrefAttr.localName()) || name == srcAttr || name == actionAttr) && protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value));       
+{
+    return (name.localName() == hrefAttr.localName() || name.localName() == nohrefAttr.localName()
+        || name == srcAttr || name == actionAttr || name == formactionAttr) && protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(value));
 }
 
 void Element::parserSetAttributes(const Vector<Attribute>& attributeVector, FragmentScriptingPermission scriptingPermission)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to