From: Nuno Lopes Date: Sun, 27 May 2007 15:57:11 +0000 (+0000) Subject: fix handling of && by htmlentities 'no-double-encode' X-Git-Tag: php-5.2.3~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c5368c013f287ed8bc88ecd52c0350f420c9738;p=php fix handling of && by htmlentities 'no-double-encode' expand the test cases --- diff --git a/ext/standard/html.c b/ext/standard/html.c index a5f5292c33..5b102f3d82 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1154,7 +1154,7 @@ encode_amp: len += sizeof("&") - 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; diff --git a/ext/standard/tests/strings/htmlentities18.phpt b/ext/standard/tests/strings/htmlentities18.phpt index f171adaca2..ab3df05da8 100644 --- a/ext/standard/tests/strings/htmlentities18.phpt +++ b/ext/standard/tests/strings/htmlentities18.phpt @@ -9,6 +9,9 @@ $tests = array( "&; & &#a; &9;", "&kffjadfdhsjfhjasdhffasdfas;", "�", + "&", + "&&&", + "&ab&&", ); foreach ($tests as $test) { @@ -23,9 +26,15 @@ string(13) "abc&sfdsa" string(13) "abc&sfdsa" string(33) "test+s & some more D" string(33) "test+s & some more D" -string(20) "&; &amp &#a; &9;" -string(20) "&; &amp &#a; &9;" +string(24) "&; &amp &#a; &9;" +string(24) "&; &amp &#a; &9;" string(32) "&kffjadfdhsjfhjasdhffasdfas;" string(32) "&kffjadfdhsjfhjasdhffasdfas;" string(16) "&#8787978789" string(16) "&#8787978789" +string(5) "&" +string(5) "&" +string(15) "&&&" +string(15) "&&&" +string(17) "&ab&&" +string(17) "&ab&&"