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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC