php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15160 strip_tags problem with <!-- javascript --> comments inside tags
Submitted: 2002-01-22 07:24 UTC Modified: 2002-01-22 14:29 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: martin at humany dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.1.1 OS: Linux 2.4 and Windows XP
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: martin at humany dot com
New email:
PHP Version: OS:

 

 [2002-01-22 07:24 UTC] martin at humany dot com
I experienced problems with strip_tags on javascript inside <!-- //--> brackets that also contains //comments. Below is first two properly working examples, then a example to reproduce the problem. Tested in both Windows XP and Linux 2.4, both with PHP 4.1.1

$data = "<br>hello there<!-- comment // --><br>";
$out = strip_tags($data);
echo $out;
//$out = hello there, as expected :)
	
$data = "<br>hello there<!-- comment --><br>";
$out = strip_tags($data);
echo $out;
//$out = hello there, as expected :)


$data = "<!-- \n".
	"function a(i) {\n".
	"// comment\n".
	"var x=1;\n".
	"if (i>1) x=2;\n".
	"}\n".
	"// -->";
$out = strip_tags($data);
echo $out;
	
$out now is:
1) x=2;
}
// -->

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-22 14:29 UTC] sander@php.net
strip_tags removes everything between < and the _first_ occurence of >
If you have "<abc> >" it returns " >".
Not a bug.
If you want to remove a whole comment, you need to use a regex.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 06:01:27 2019 UTC