lbarnaud Fri Apr 24 21:23:48 2009 UTC Added files: /php-src/ext/standard/tests/strings bug21453_binary.phpt bug21744_binary.phpt bug22008_binary.phpt bug23650_binary.phpt bug40432_binary.phpt bug40637_binary.phpt bug40704_binary.phpt bug45485_binary.phpt bug46578_binary.phpt strip_tags_basic1_binary.phpt strip_tags_basic2_binary.phpt strip_tags_error_binary.phpt strip_tags_binary.phpt strip_tags_variation10_binary.phpt strip_tags_variation11_binary.phpt strip_tags_variation4_binary.phpt strip_tags_variation5_binary.phpt strip_tags_variation6_binary.phpt strip_tags_variation7_binary.phpt strip_tags_variation8_binary.phpt strip_tags_variation9_binary.phpt
Modified files: /php-src/ext/standard/tests/strings strip_tags_variation4.phpt strip_tags_variation7.phpt /php-src/ext/standard string.c Log: strip_tags() fixes: - MFH5.3 (Fix bug when < is used within attribute.) - Fix handling of case when searching for allowed tags in unicode variant - tests for both unicode and binary variants
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation4.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/strings/strip_tags_variation4.phpt diff -u php-src/ext/standard/tests/strings/strip_tags_variation4.phpt:1.3 php-src/ext/standard/tests/strings/strip_tags_variation4.phpt:1.4 --- php-src/ext/standard/tests/strings/strip_tags_variation4.phpt:1.3 Tue May 27 10:50:46 2008 +++ php-src/ext/standard/tests/strings/strip_tags_variation4.phpt Fri Apr 24 21:23:47 2009 @@ -56,9 +56,9 @@ -- Iteration 4 -- unicode(0) "" -- Iteration 5 -- -unicode(5) "hello" +unicode(18) "<htmL>hello</htmL>" -- Iteration 6 -- -unicode(5) "hello" +unicode(18) "<htmL>hello</htmL>" -- Iteration 7 -- unicode(9) "HtMl text" -- Iteration 8 -- http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation7.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/strings/strip_tags_variation7.phpt diff -u php-src/ext/standard/tests/strings/strip_tags_variation7.phpt:1.3 php-src/ext/standard/tests/strings/strip_tags_variation7.phpt:1.4 --- php-src/ext/standard/tests/strings/strip_tags_variation7.phpt:1.3 Tue May 27 10:50:46 2008 +++ php-src/ext/standard/tests/strings/strip_tags_variation7.phpt Fri Apr 24 21:23:47 2009 @@ -54,9 +54,9 @@ -- Iteration 4 -- unicode(0) "" -- Iteration 5 -- -unicode(5) "hello" +unicode(18) "<htmL>hello</htmL>" -- Iteration 6 -- -unicode(5) "hello" +unicode(18) "<htmL>hello</htmL>" -- Iteration 7 -- unicode(9) "HtMl text" -- Iteration 8 -- http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.697&r2=1.698&diff_format=u Index: php-src/ext/standard/string.c diff -u php-src/ext/standard/string.c:1.697 php-src/ext/standard/string.c:1.698 --- php-src/ext/standard/string.c:1.697 Wed Apr 1 17:04:16 2009 +++ php-src/ext/standard/string.c Fri Apr 24 21:23:47 2009 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: string.c,v 1.697 2009/04/01 17:04:16 mattwil Exp $ */ +/* $Id: string.c,v 1.698 2009/04/24 21:23:47 lbarnaud Exp $ */ /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */ @@ -6253,7 +6253,8 @@ while (!done) { U16_NEXT(tag, idx, len, ch); - switch (u_tolower(ch)) { + ch = u_tolower(ch); + switch (ch) { case '<': *(n++) = ch; break; @@ -6403,6 +6404,9 @@ break; case 0x3C: /* '<' */ + if (in_q) { + break; + } U16_GET(buf, 0, idx, len, next); if (u_isWhitespace(next) == TRUE) { goto reg_u_char; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug21453_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug21453_binary.phpt +++ php-src/ext/standard/tests/strings/bug21453_binary.phpt --TEST-- Bug #21453 (handling of non-encoded <), binary variant --FILE-- <?php $test = b" <table> <tr><td>first cell before < first cell after</td></tr> <tr><td>second cell before < second cell after</td></tr> </table>"; var_dump(strip_tags($test)); ?> --EXPECT-- string(80) " first cell before < first cell after second cell before < second cell after " http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug21744_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug21744_binary.phpt +++ php-src/ext/standard/tests/strings/bug21744_binary.phpt --TEST-- Bug #21744 (strip_tags misses exclamation marks in alt text), binary variant --FILE-- <?php $test = (binary) <<< HERE <a href="test?test\\!!!test">test</a> <!-- test --> HERE; print strip_tags($test, ''); print strip_tags($test, '<a>'); ?> --EXPECT-- test <a href="test?test\!!!test">test</a> http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug22008_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug22008_binary.phpt +++ php-src/ext/standard/tests/strings/bug22008_binary.phpt --TEST-- Bug #22008 (strip_tags() eliminates too much), binary variant --FILE-- <?php $html = (binary) <<< HERE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>test</title> </head> <body> <b>PHP!</b> </body> </html> HERE; echo trim(strip_tags($html, '<b>'))."\n"; ?> --EXPECT-- test <b>PHP!</b> http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug23650_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug23650_binary.phpt +++ php-src/ext/standard/tests/strings/bug23650_binary.phpt --TEST-- Bug #23650 (strip_tags() removes hyphens), binary variant --FILE-- <?php $str = (binary) <<< HERE 1:<!-- abc - --> 2:<!doctype -- > 3: 4:<abc - def> 5:abc - def 6:</abc> HERE; echo strip_tags($str); echo strip_tags($str, b'<abc>'); ?> --EXPECT-- 1: 2: 3: 4: 5:abc - def 6: 1: 2: 3: 4:<abc - def> 5:abc - def 6:</abc> http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40432_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug40432_binary.phpt +++ php-src/ext/standard/tests/strings/bug40432_binary.phpt --TEST-- Bug #40432 (strip_tags() fails with greater than in attribute), binary variant --FILE-- <?php echo strip_tags(b'<span title="test > all">this</span>') . "\n"; ?> --EXPECT-- this http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40637_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug40637_binary.phpt +++ php-src/ext/standard/tests/strings/bug40637_binary.phpt --TEST-- Bug #40637 (strip_tags() does not handle single quotes correctly), binary variant --FILE-- <?php $html = b'<span title="Bug \' Trigger">Text</span>'; var_dump(strip_tags($html)); echo "Done\n"; ?> --EXPECT-- unicode(4) "Text" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40704_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug40704_binary.phpt +++ php-src/ext/standard/tests/strings/bug40704_binary.phpt --TEST-- Bug #40704 (strip_tags() does not handle single quotes correctly), binary variant --FILE-- <?php $html = b"<div>Bug ' Trigger</div> Missing Text"; var_dump(strip_tags($html)); echo "Done\n"; ?> --EXPECT-- string(26) "Bug ' Trigger Missing Text" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug45485_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug45485_binary.phpt +++ php-src/ext/standard/tests/strings/bug45485_binary.phpt --TEST-- Bug #45485 (strip_tags and <?XML tag), binary variant --FILE-- <?php $s = (binary) <<< EOD This text is shown <?XML:NAMESPACE PREFIX = ST1 /><b>This Text disappears</b> EOD; $s = strip_tags($s); echo htmlspecialchars($s),"\n"; $s = (binary) <<< EOD This text is shown <?xml:NAMESPACE PREFIX = ST1 /><b>This Text disappears</b> EOD; $s = strip_tags($s); echo htmlspecialchars($s),"\n"; ?> --EXPECT-- This text is shown This Text disappears This text is shown This Text disappears http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug46578_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/bug46578_binary.phpt +++ php-src/ext/standard/tests/strings/bug46578_binary.phpt --TEST-- Bug #46578 (strip_tags() does not honor end-of-comment when it encounters a single quote), binary variant --FILE-- <?php var_dump(strip_tags(b'<!-- testing I\'ve been to mars -->foobar')); var_dump(strip_tags(b'<a alt="foobar">foo<!-- foo! --></a>bar')); var_dump(strip_tags(b'<a alt="foobar"/>foo<?= foo! /* <!-- "cool" --> */ ?>bar')); var_dump(strip_tags(b'< ax')); var_dump(strip_tags(b'<! a>')); var_dump(strip_tags(b'<? ax')); ?> --EXPECTF-- string(6) "foobar" string(6) "foobar" string(6) "foobar" string(4) "< ax" string(0) "" string(0) "" http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_basic1_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_basic1_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_basic1_binary.phpt --TEST-- Test strip_tags() function : basic functionality - with default arguments, binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ echo "*** Testing strip_tags() : basic functionality ***\n"; // array of arguments $string_array = array ( b"<html>hello</html>", b'<html>hello</html>', b"<?php echo hello ?>", b'<?php echo hello ?>', b"<? echo hello ?>", b'<? echo hello ?>', b"<% echo hello %>", b'<% echo hello %>', b"<script language=\"PHP\"> echo hello </script>", b'<script language=\"PHP\"> echo hello </script>', b"<html><b>hello</b><p>world</p></html>", b'<html><b>hello</b><p>world</p></html>', b"<html><!-- COMMENT --></html>", b'<html><!-- COMMENT --></html>' ); // Calling strip_tags() with default arguments // loop through the $string_array to test strip_tags on various inputs $iteration = 1; foreach($string_array as $string) { echo "-- Iteration $iteration --\n"; var_dump( strip_tags($string) ); $iteration++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : basic functionality *** -- Iteration 1 -- string(5) "hello" -- Iteration 2 -- string(5) "hello" -- Iteration 3 -- string(0) "" -- Iteration 4 -- string(0) "" -- Iteration 5 -- string(0) "" -- Iteration 6 -- string(0) "" -- Iteration 7 -- string(0) "" -- Iteration 8 -- string(0) "" -- Iteration 9 -- string(12) " echo hello " -- Iteration 10 -- string(12) " echo hello " -- Iteration 11 -- string(10) "helloworld" -- Iteration 12 -- string(10) "helloworld" -- Iteration 13 -- string(0) "" -- Iteration 14 -- string(0) "" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_basic2_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_basic2_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_basic2_binary.phpt --TEST-- Test strip_tags() function : basic functionality - with all arguments, binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ echo "*** Testing strip_tags() : basic functionality ***\n"; // Calling strip_tags() with all possible arguments $string = b"<html><p>hello</p><b>world</b><a href=\"#fragment\">Other text</a></html><?php echo hello ?>"; $allowed_tags_array=array( b"<html>", b'<html>', b"<p>", b'<p>', b"<a>", b'<a>', b"<?php", b'<?php', b"<html><p><a><?php" ); // loop through the $string with various $allowed_tags_array to test strip_tags // on various allowed tags $iteration = 1; foreach($allowed_tags_array as $tags) { echo "-- Iteration $iteration --\n"; var_dump( strip_tags($string, $tags) ); $iteration++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : basic functionality *** -- Iteration 1 -- string(33) "<html>helloworldOther text</html>" -- Iteration 2 -- string(33) "<html>helloworldOther text</html>" -- Iteration 3 -- string(27) "<p>hello</p>worldOther text" -- Iteration 4 -- string(27) "<p>hello</p>worldOther text" -- Iteration 5 -- string(44) "helloworld<a href="#fragment">Other text</a>" -- Iteration 6 -- string(44) "helloworld<a href="#fragment">Other text</a>" -- Iteration 7 -- string(20) "helloworldOther text" -- Iteration 8 -- string(20) "helloworldOther text" -- Iteration 9 -- string(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_error_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_error_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_error_binary.phpt --TEST-- Test strip_tags() function : error conditions, binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ echo "*** Testing strip_tags() : error conditions ***\n"; // Zero arguments echo "\n-- Testing strip_tags() function with Zero arguments --\n"; var_dump( strip_tags() ); //Test strip_tags with one more than the expected number of arguments echo "\n-- Testing strip_tags() function with more than expected no. of arguments --\n"; $str = b"<html>hello</html>"; $allowable_tags = b"<html>"; $extra_arg = 10; var_dump( strip_tags($str, $allowable_tags, $extra_arg) ); echo "Done"; ?> --EXPECTF-- *** Testing strip_tags() : error conditions *** -- Testing strip_tags() function with Zero arguments -- Warning: strip_tags() expects at least 1 parameter, 0 given in %s on line %d NULL -- Testing strip_tags() function with more than expected no. of arguments -- Warning: strip_tags() expects at most 2 parameters, 3 given in %s on line %d NULL Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_binary.phpt --TEST-- strip_tags() function, binary variant --FILE-- <?php echo strip_tags(b'NEAT <? cool < blah ?> STUFF'); echo "\n"; echo strip_tags(b'NEAT <? cool > blah ?> STUFF'); echo "\n"; echo strip_tags(b'NEAT <!-- cool < blah --> STUFF'); echo "\n"; echo strip_tags(b'NEAT <!-- cool > blah --> STUFF'); echo "\n"; echo strip_tags(b'NEAT <? echo \"\\\"\"?> STUFF'); echo "\n"; echo strip_tags(b'NEAT <? echo \'\\\'\'?> STUFF'); echo "\n"; echo strip_tags(b'TESTS ?!!?!?!!!?!!'); echo "\n"; ?> --EXPECT-- NEAT STUFF NEAT STUFF NEAT STUFF NEAT STUFF NEAT STUFF NEAT STUFF TESTS ?!!?!?!!!?!! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation10_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation10_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation10_binary.phpt --TEST-- Test strip_tags() function : usage variations - single quoted strings, binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving single quoted strings as values for $str argument */ echo "*** Testing strip_tags() : usage variations ***\n"; $single_quote_string = array ( b'<html> \$ -> This represents the dollar sign</html><?php echo hello ?>', b'<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>', b'<a>This is a hyper text tag</a>', b'<? <html>hello world\\t</html>?>', b'<p>This is a paragraph</p>', b'<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>' ); $quotes = b"<html><a><p><b><?php"; //loop through the various elements of strings array to test strip_tags() functionality $iterator = 1; foreach($single_quote_string as $string_value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags($string_value, $quotes) ); $iterator++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(51) "<html> \$ -> This represents the dollar sign</html>" -- Iteration 2 -- string(63) "<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>" -- Iteration 3 -- string(31) "<a>This is a hyper text tag</a>" -- Iteration 4 -- string(0) "" -- Iteration 5 -- string(26) "<p>This is a paragraph</p>" -- Iteration 6 -- string(65) "<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation11_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation11_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation11_binary.phpt --TEST-- Test strip_tags() function : obscure values within attributes, binary variant --INI-- short_open_tag = on --FILE-- <?php echo "*** Testing strip_tags() : obscure functionality ***\n"; // array of arguments $string_array = array ( b'hello <img title="<"> world', b'hello <img title=">"> world', b'hello <img title=">_<"> world', b"hello <img title='>_<'> world" ); // Calling strip_tags() with default arguments // loop through the $string_array to test strip_tags on various inputs $iteration = 1; foreach($string_array as $string) { echo "-- Iteration $iteration --\n"; var_dump( strip_tags($string) ); $iteration++; } echo "Done"; ?> --EXPECTF-- *** Testing strip_tags() : obscure functionality *** -- Iteration 1 -- string(12) "hello world" -- Iteration 2 -- string(12) "hello world" -- Iteration 3 -- string(12) "hello world" -- Iteration 4 -- string(12) "hello world" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation4_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation4_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation4_binary.phpt --TEST-- Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags', binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving invalid values for $str and valid values for $allowable_tags argument */ echo "*** Testing strip_tags() : usage variations ***\n"; // unexpected values for $string $strings = array ( b"<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>", b'<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>', b"<%?php hello\t world?%>", b'<%?php hello\t world?%>', b"<<htmL>>hello<</htmL>>", b'<<htmL>>hello<</htmL>>', b"<a.>HtMl text</.a>", b'<a.>HtMl text</.a>', b"<nnn>I am not a valid html text</nnn>", b'<nnn>I am not a valid html text</nnn>', b"<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>", b'<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>', ); //valid html and php tags $quotes = b"<p><a><?php<html>"; //loop through the various elements of strings array to test strip_tags() functionality $iterator = 1; foreach($strings as $string_value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags($string_value, $quotes) ); $iterator++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(32) "hello world... strip_tags_test" -- Iteration 2 -- string(34) "hello \t\tworld... strip_tags_test" -- Iteration 3 -- string(0) "" -- Iteration 4 -- string(0) "" -- Iteration 5 -- string(18) "<htmL>hello</htmL>" -- Iteration 6 -- string(18) "<htmL>hello</htmL>" -- Iteration 7 -- string(9) "HtMl text" -- Iteration 8 -- string(9) "HtMl text" -- Iteration 9 -- string(26) "I am not a valid html text" -- Iteration 10 -- string(26) "I am not a valid html text" -- Iteration 11 -- string(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&" -- Iteration 12 -- string(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation5_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation5_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation5_binary.phpt --TEST-- Test strip_tags() function : usage variations - heredoc strings, binary variant --INI-- set short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving heredoc strings as values for $str argument */ echo "*** Testing strip_tags() : usage variations ***\n"; // null here doc string $null_string = <<<EOT EOT; // heredoc string with blank line $blank_line = <<<EOT EOT; // here doc with multiline string $multiline_string = <<<EOT <html>hello world</html> <p>13 < 25</p> <?php 1111 & 0000 = 0000 ?> <b>This is a double quoted string</b> EOT; // here doc with diferent whitespaces $diff_whitespaces = <<<EOT <html>hello\r world\t 1111\t\t != 2222\v\v</html> <? heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces ?> EOT; // here doc with numeric values $numeric_string = <<<EOT <html>11 < 12. 123 >22</html> <p>string</p> 1111\t <b>0000\t = 0000\n</b> EOT; // heredoc with quote chars & slash $quote_char_string = <<<EOT <html>This's a string with quotes:</html> "strings in double quote"; 'strings in single quote'; <html>this\line is single quoted /with\slashes </html> EOT; $res_heredoc_strings = array( //heredoc strings $null_string, $blank_line, $multiline_string, $diff_whitespaces, $numeric_string, $quote_char_string ); // initialize the second argument $quotes = "<html><a><?php"; // loop through $res_heredoc_strings element and check the working on strip_tags() $count = 1; for($index =0; $index < count($res_heredoc_strings); $index ++) { echo "-- Iteration $count --\n"; var_dump( strip_tags((binary)$res_heredoc_strings[$index], (binary)$quotes) ); $count++; } echo "Done\n"; ?> --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(0) "" -- Iteration 2 -- string(0) "" -- Iteration 3 -- string(67) "<html>hello world</html> 13 < 25 This is a double quoted string" -- Iteration 4 -- string(44) "<html>hello world 1111 != 2222</html> " -- Iteration 5 -- string(56) "<html>11 < 12. 123 >22</html> string 1111 0000 = 0000 " -- Iteration 6 -- string(150) "<html>This's a string with quotes:</html> "strings in double quote"; 'strings in single quote'; <html>this\line is single quoted /with\slashes </html>" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation6_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation6_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation6_binary.phpt --TEST-- Test strip_tags() function : usage variations - binary safe checking, binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing whether strip_tags() is binary safe or not */ echo "*** Testing strip_tags() : usage variations ***\n"; //various string inputs $strings = array ( "<html> I am html string </html>".chr(0)."<?php I am php string ?>", "<html> I am html string\0 </html><?php I am php string ?>", b"<a>I am html string</a>", "<html>I am html string</html>".decbin(65)."<?php I am php string?>" ); //loop through the strings array to check if strip_tags() is binary safe $iterator = 1; foreach($strings as $value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags((binary)$value) ); $iterator++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(18) " I am html string " -- Iteration 2 -- string(18) " I am html string " -- Iteration 3 -- string(16) "I am html string" -- Iteration 4 -- string(23) "I am html string1000001" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation7_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation7_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation7_binary.phpt --TEST-- Test strip_tags() function : usage variations - invalid values for 'str' and 'allowable_tags', binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving invalid values for $str and $allowable_tags argument */ echo "*** Testing strip_tags() : usage variations ***\n"; $strings = array ( b"<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>", b'<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>', b"<%?php hello\t world?%>", b'<%?php hello\t world?%>', b"<<htmL>>hello<</htmL>>", b'<<htmL>>hello<</htmL>>', b"<a.>HtMl text</.a>", b'<a.>HtMl text</.a>', b"<nnn>I am not a valid html text</nnn>", b'<nnn>I am not a valid html text</nnn>', b"<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>", b'<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>', ); $quotes = b"<nnn><abc><%?<<html>>"; //loop through the various elements of strings array to test strip_tags() functionality $iterator = 1; foreach($strings as $string_value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags($string_value, $quotes) ); $iterator++; } echo "Done"; ?> --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(43) "<abc>hello</abc> world... strip_tags_test" -- Iteration 2 -- string(45) "<abc>hello</abc> \t\tworld... strip_tags_test" -- Iteration 3 -- string(0) "" -- Iteration 4 -- string(0) "" -- Iteration 5 -- string(18) "<htmL>hello</htmL>" -- Iteration 6 -- string(18) "<htmL>hello</htmL>" -- Iteration 7 -- string(9) "HtMl text" -- Iteration 8 -- string(9) "HtMl text" -- Iteration 9 -- string(37) "<nnn>I am not a valid html text</nnn>" -- Iteration 10 -- string(37) "<nnn>I am not a valid html text</nnn>" -- Iteration 11 -- string(73) "<nnn>I am a quoted (") string with special chars like $,\!,\@,\%,\&</nnn>" -- Iteration 12 -- string(75) "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation8_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation8_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation8_binary.phpt --TEST-- Test strip_tags() function : usage variations - valid value for 'str' and invalid values for 'allowable_tags', binary variant --INI-- short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving valid value for $str and invalid values for $allowable_tags argument */ echo "*** Testing strip_tags() : usage variations ***\n"; $strings = b"<html>hello</html> \tworld... <p>strip_tags_test\v\f</p><?php hello\t wo\rrld?>"; $quotes = array ( b"<nnn>", b'<nnn>', b"<abc>", b'<abc>', b"<%?php", b'<%?php', b"<<html>>", b'<<html>>' ); //loop through the various elements of strings array to test strip_tags() functionality $iterator = 1; foreach($quotes as $string_value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags($strings, $string_value) ); $iterator++; } echo "Done"; --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(33) "hello world... strip_tags_test" -- Iteration 2 -- string(33) "hello world... strip_tags_test" -- Iteration 3 -- string(33) "hello world... strip_tags_test" -- Iteration 4 -- string(33) "hello world... strip_tags_test" -- Iteration 5 -- string(33) "hello world... strip_tags_test" -- Iteration 6 -- string(33) "hello world... strip_tags_test" -- Iteration 7 -- string(46) "<html>hello</html> world... strip_tags_test" -- Iteration 8 -- string(46) "<html>hello</html> world... strip_tags_test" Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation9_binary.phpt?view=markup&rev=1.1 Index: php-src/ext/standard/tests/strings/strip_tags_variation9_binary.phpt +++ php-src/ext/standard/tests/strings/strip_tags_variation9_binary.phpt --TEST-- Test strip_tags() function : usage variations - double quoted strings, binary variant --INI-- set short_open_tag = on --FILE-- <?php /* Prototype : string strip_tags(string $str [, string $allowable_tags]) * Description: Strips HTML and PHP tags from a string * Source code: ext/standard/string.c */ /* * testing functionality of strip_tags() by giving double quoted strings as values for $str argument */ echo "*** Testing strip_tags() : usage variations ***\n"; $double_quote_string = array ( b"<html> \$ -> This represents the dollar sign</html><?php echo hello ?>", b"<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>", b"<a>This is a hyper text tag</a>", b"<? <html>hello world\\t</html>?>", b"<p>This is a paragraph</p>", b"<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>" ); $quotes = b"<html><a><p><b><?php"; //loop through the various elements of strings array to test strip_tags() functionality $iterator = 1; foreach($double_quote_string as $string_value) { echo "-- Iteration $iterator --\n"; var_dump( strip_tags($string_value, $quotes) ); $iterator++; } echo "Done"; --EXPECT-- *** Testing strip_tags() : usage variations *** -- Iteration 1 -- string(50) "<html> $ -> This represents the dollar sign</html>" -- Iteration 2 -- string(59) "<html> The quick brown fox jumped over the lazy dog</p>" -- Iteration 3 -- string(31) "<a>This is a hyper text tag</a>" -- Iteration 4 -- string(0) "" -- Iteration 5 -- string(26) "<p>This is a paragraph</p>" -- Iteration 6 -- string(62) "<b>This is a text in bold letters\s\malong with slashes </b>" Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php