|  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
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";


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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-21 19:18 UTC]
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
Thank you for the report, and for helping us make PHP better.

 [2008-11-21 22:29 UTC]
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: Sun Feb 25 23:01:33 2024 UTC