php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29198 strip_tags silently strips out <!...> tags
Submitted: 2004-07-16 06:01 UTC Modified: 2004-12-28 04:37 UTC
From: steven at acko dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.0.0 OS: Windows 2000
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: steven at acko dot net
New email:
PHP Version: OS:

 

 [2004-07-16 06:01 UTC] steven at acko dot net
Description:
------------
The strip_tags function is hardcoded to strip out <!...> tags, such as comments.

It is IMO expected behaviour for the function that specifying "<!-->" or "<!DOCTYPE>" in the allowed tags list leaves these intact.

If this is expected behaviour for this function, then the documentation should be updated.

(PS: The state machine in php_strip_tags() in string.c seems to contain some redundancies. Someone who understand all of it should take a closer look ;))

Reproduce code:
---------------
<?php
  print strip_tags("Some text. <!-- a comment --> Some text.", "<!-->");
?>

Expected result:
----------------
The output should be:
Some text. <!-- a comment --> Some text.
(with the comment intact)

Actual result:
--------------
The output is:
Some text.  Some text.
(the comment is stripped out)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-28 00:44 UTC] support at jevon dot org
Isn't this already documented?

http://nz2.php.net/strip_tags
 [2004-12-28 04:37 UTC] steven at acko dot net
I checked the English documentation and indeed, it is documented there. It is missing from the Dutch translation of that page, which php.net defaults to, hence I didn't notice it.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 08:01:24 2019 UTC