php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46578 strip_tags() does not honor end-of-comment when it encounters a single quote
Submitted: 2008-11-15 11:40 UTC Modified: 2008-11-21 22:29 UTC
From: j at ww dot com Assigned:
Status: Closed Package: Strings related
PHP Version: 5CVS, 6CVS (2008-11-21) OS: *
Private report: No CVE-ID: None
 [2008-11-15 11:40 UTC] j at ww dot com
Description:
------------
There is a nasty little gotcha in 'strip_tags', if you have a single quote inside an html comment strip_tags will ignore the end-of-comment tag!

So, <!-- test --> this works, but <!-- test I've --> this does not, the end-of-comment tag will be ignored.



Reproduce code:
---------------
$i = "<!-- testing I've been to mars --> quite so";

echo(strip_tags($i));



Expected result:
----------------
It should read "quite so", instead it returns a blank string, presumably because no end quote was encountered (the parser has probably switched into 'attribute' mode, but in a comment there are no attributes). Adding another quote to the above example will verify this hypothesis.



Actual result:
--------------
an empty string.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-21 19:18 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2008-11-21 22:29 UTC] jani@php.net
Note: Fixed in PHP_5_3 and HEAD branches. Fix will NOT be in PHP 
5.2.7 release!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC