#34863 [Opn->Fbk]: strip_tags cannot work when string include <img tags
ID: 34863
Updated by: tony2001@php.net
Reported By: backdream at gmail dot com
-Status: Open
+Status: Feedback
-Bug Type: Scripting Engine problem
+Bug Type: Strings related
Operating System: Windows
PHP Version: 4.4.0
New Comment:
Can't reproduce.
Both your scripts work fine with any PHP version I can find (4.3.11,
4.4, 5.0.x, 5.1).
Previous Comments:
------------------------------------------------------------------------
[2005-10-14 03:31:24] backdream at gmail dot com
Sorry, the Reproduce code would be:
---------------
<?php
$txt = "Next: <a
href=\"http://www.joelonsoftware.com/uibook/chapters/fog0000000063.html\
" target=\"_blank\">Designing for People Who Have Better Things To Do
With Their Lives, Part Two</a> <br />¡¡¡¡<br />¡¡¡¡<img
src=\"http://86.0.190.20/test/ipb21/skin_acp/IPB2_Standard/images/users.
png\" border=\"0\" align=\"absmiddle\" alt=\"Á´½ÓͼƬ\"
onload=\"if(screen.width*0.7<this.width) {this.resized=true;
this.width=screen.width*0.7;}\" /><br />¡¡¡¡<b>Adverment!</b>
Do
you
need to control a computer remotely, even when firewalls get in the
way?
My company's latest product, <a href=\"https://www.copilot.com/\"
target=\"_blank\">Fog Creek Copilot</a>, is a remote control system
that
requires no setup, no configuration, and works even if both users are
behind firewalls. It's designed to make remote tech support easy.
<br />¡¡¡¡<br />¡¡¡¡Enter your email address to receive a (very
occasional) email whenever I write a major new article. You can
unsubscribe at any time, of course.<br />¡¡¡¡</div>";
$txt = strip_tags( $txt );
print $txt;
?>
------------------------------------------------------------------------
[2005-10-14 03:24:18] backdream at gmail dot com
Description:
------------
strip_tags cannot work when string include <img tags
Reproduce code:
---------------
<?php
$txt = "Next: <a
href=\"http://www.joelonsoftware.com/uibook/chapters/fog0000000063.html\"
target=\"_blank\">Designing for People Who Have Better Things To Do With
Their Lives, Part Two</a> <br />¡¡¡¡<br />¡¡¡¡<img
src=\"http://86.0.190.20/test/ipb21/skin_acp/IPB2_Standard/images/users.png\"
border=\"0\" align=\"absmiddle\" alt=\"Á´½ÓͼƬ\"
onload=\"if(screen.width*0.7<this.width) {this.resized=true;
this.width=screen.width*0.7;}\" /><br />¡¡¡¡<b>Adverment!</b>
Do
you need to control a computer remotely, even when firewalls get in the
way? My company's latest product, <a
href=\"https://www.copilot.com/\"
target=\"_blank\">Fog Creek
Copilot</a>, is a remote control system that requires no setup, no
configuration, and works even if both users are behind firewalls.
It's designed to make remote tech support easy. <br />¡¡¡¡<br
/>¡¡¡¡Enter your email address to receive a (very occasional) email
whenever I write a major new article. You can unsubscribe at any time,
of course.<br />¡¡¡¡</div>";
$txt = preg_replace( "#<img[^>]*>#i", "", $txt );
$txt = strip_tags( $txt );
print $txt;
?>
Expected result:
----------------
strip all the html tags
Actual result:
--------------
break when run over <img tag.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34863&edit=1
Thread (6 messages)