Req #71286 [Opn->Nab]: strip_tags should remove non-text chararcters as well

From: Date: Tue, 05 Jan 2016 16:26:11 +0000
Subject: Req #71286 [Opn->Nab]: strip_tags should remove non-text chararcters as well
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198432@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71286&edit=1 ID: 71286 Updated by: tyrael@php.net Reported by: leesleefeng at 163 dot com Summary: strip_tags should remove non-text chararcters as well -Status: Open +Status: Not a bug Type: Feature/Change Request Package: Strings related Operating System: All PHP Version: 5.6.16 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php by that same logic any well-formed html or xml string should result in an empty string. strip_tags() doesn't work like that, and you can see that from the second example of the official documentation: http://php.net/strip_tags#example-5473 Previous Comments: ------------------------------------------------------------------------ [2016-01-05 15:42:22] leesleefeng at 163 dot com Description: ------------ strip_tags should remove non-text chararcters as well. When using strip_tags to remove html and php tags, the purpose is to get plain text. Thus if the tags has codes but not text inside, like style tag and script tag, the codes should be removed as well, not noly the tags. Test script: --------------- $s = <<<html <style type="text/css"> body,h1,h2,h3,h4,h5,h6{padding:0;margin:0;} </style> <script> window.onload = function(){ console.log('document is ready'); } </script> <div> walking through the green fields, sunshine in my eyes </div> html; $text = strip_tags($s); echo $text; Expected result: ---------------- walking through the green fields, sunshine in my eyes Actual result: -------------- body,h1,h2,h3,h4,h5,h6{padding:0;margin:0;} window.onload = function(){ console.log('document is ready'); } walking through the green fields, sunshine in my eyes ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71286&edit=1

« previous php.bugs (#198432) next »