#34863 [Fbk->Opn]: strip_tags cannot work when string include <img tags

From: Date: Fri, 14 Oct 2005 17:36:27 +0000
Subject: #34863 [Fbk->Opn]: strip_tags cannot work when string include <img tags
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86601@lists.php.net to get a copy of this message
ID: 34863 User updated by: backdream at gmail dot com Reported By: backdream at gmail dot com -Status: Feedback +Status: Open Bug Type: Strings related Operating System: Windows -PHP Version: 4.4.0 +PHP Version: 4.3.11 New Comment: I tested with 4.3.11, It also have the bug. ------ <?php $txt = "Next: <ahref=\"http://www.joelonsoftware.com/uibook/chapters/fog0000000063.html\" target=\"_blank\">Designing for People Who Have Better Things To DoWith Their Lives, Part Two</a> <br />¡¡¡¡<br />¡¡¡¡<imgsrc=\"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&#33;</b> Doyouneed to control a computer remotely, even when firewalls get in theway?My company&#39;s latest product, <a href=\"https://www.copilot.com/\"target=\"_blank\">Fog Creek Copilot</a>, is a remote control systemthatrequires no setup, no configuration, and works even if both users arebehind firewalls. It&#39;s designed to make remote tech support easy.<br />¡¡¡¡<br />¡¡¡¡Enter your email address to receive a (veryoccasional) email whenever I write a major new article. You canunsubscribe at any time, of course.<br />¡¡¡¡</div>"; $txt = strip_tags( $txt ); print $txt; ?> ----------- It print "Next: Designing for People Who Have Better Things To DoWith Their Lives, Part Two ¡¡¡¡¡¡¡¡", but not the whole html tags striped string. Previous Comments: ------------------------------------------------------------------------ [2005-10-14 13:18:53] tony2001@php.net 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). ------------------------------------------------------------------------ [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&#33;</b> Do you need to control a computer remotely, even when firewalls get in the way? My company&#39;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&#39;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&#33;</b> Do you need to control a computer remotely, even when firewalls get in the way? My company&#39;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&#39;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

« previous php.bugs (#86601) next »