]> source.dussan.org Git - jquery.git/commitdiff
Fixes #11402. domManip now also removes the closing part of HTML comments or CDATA...
authorjaubourg <j@ubourg.net>
Sat, 5 May 2012 23:27:01 +0000 (01:27 +0200)
committerjaubourg <j@ubourg.net>
Sat, 5 May 2012 23:27:01 +0000 (01:27 +0200)
src/manipulation.js
test/data/cleanScript.html [new file with mode: 0644]
test/unit/ajax.js

index cc6acee821e5028edba02c2df9115f10d82d1c0b..888c9f33c10148f7bd70267899d57497410ff7fd 100644 (file)
@@ -29,7 +29,7 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
        // checked="checked" or checked
        rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
        rscriptType = /\/(java|ecma)script/i,
-       rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
+       rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
        wrapMap = {
                option: [ 1, "<select multiple='multiple'>", "</select>" ],
                legend: [ 1, "<fieldset>", "</fieldset>" ],
diff --git a/test/data/cleanScript.html b/test/data/cleanScript.html
new file mode 100644 (file)
index 0000000..69288a8
--- /dev/null
@@ -0,0 +1,10 @@
+<script>
+<!--
+ok( true, "script within html comments executed" );
+-->
+</script>
+<script>
+<![CDATA[
+ok( true, "script within CDATA executed" );
+]]>
+</script>
index 8be1947fb3f1091f1b4bd6b0108c89c229f024e2..d9c4c33e7db9b57f6aeac8145550083aee50c38a 100644 (file)
@@ -2467,6 +2467,14 @@ test( "jQuery.domManip - no side effect because of ajaxSetup or global events (#
        });
 });
 
+test( "jQuery.domManip - script in comments are properly evaluated (#11402)", function() {
+       expect( 2 );
+       stop();
+       jQuery( "#qunit-fixture" ).load( "data/cleanScript.html", function() {
+               start();
+       });
+});
+
 test("jQuery.ajax - active counter", function() {
     ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
 });