]> granicus.if.org Git - php/commitdiff
fix handling of && by htmlentities 'no-double-encode'
authorNuno Lopes <nlopess@php.net>
Sun, 27 May 2007 15:57:11 +0000 (15:57 +0000)
committerNuno Lopes <nlopess@php.net>
Sun, 27 May 2007 15:57:11 +0000 (15:57 +0000)
expand the test cases

ext/standard/html.c
ext/standard/tests/strings/htmlentities18.phpt

index a5f5292c3325c9802569e97e6787d4c96f6de138..5b102f3d82246f625fa1935d57d8e06746317723 100644 (file)
@@ -1154,7 +1154,7 @@ encode_amp:
                                        len += sizeof("&amp;") - 1;
                                } else {
                                        char *e = memchr(old + i, ';', oldlen - i);
-                                       char *s = old + i + 1;
+                                       char *s = old + i;
 
                                        if (!e || (e - s) > 10) { /* minor optimization to avoid "entities" over 10 chars in length */
                                                goto encode_amp;
index f171adaca2bbc433f00a900e37ae7fb02a5d321f..ab3df05da87b80a246ef37674d797371b47d01bf 100644 (file)
@@ -9,6 +9,9 @@ $tests = array(
        "&; &amp &#a; &9;",
        "&kffjadfdhsjfhjasdhffasdfas;",
        "&#8787978789",
+       "&",
+       "&&amp;&",
+       "&ab&amp;&",
 );
 
 foreach ($tests as $test) {
@@ -23,9 +26,15 @@ string(13) "abc&amp;sfdsa"
 string(13) "abc&amp;sfdsa"
 string(33) "test&#043;s &amp; some more &#68;"
 string(33) "test&#043;s &amp; some more &#68;"
-string(20) "&; &amp;amp &#a; &9;"
-string(20) "&; &amp;amp &#a; &9;"
+string(24) "&; &amp;amp &amp;#a; &9;"
+string(24) "&; &amp;amp &amp;#a; &9;"
 string(32) "&amp;kffjadfdhsjfhjasdhffasdfas;"
 string(32) "&amp;kffjadfdhsjfhjasdhffasdfas;"
 string(16) "&amp;#8787978789"
 string(16) "&amp;#8787978789"
+string(5) "&amp;"
+string(5) "&amp;"
+string(15) "&amp;&amp;&amp;"
+string(15) "&amp;&amp;&amp;"
+string(17) "&amp;ab&amp;&amp;"
+string(17) "&amp;ab&amp;&amp;"