Bug #53319 [NEW]: Strip_tags() may strip '<br />' incorrectly

From: Date: Tue, 16 Nov 2010 00:22:37 +0000
Subject: Bug #53319 [NEW]: Strip_tags() may strip '<br />' incorrectly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156069@lists.php.net to get a copy of this message
From:             
Operating system: Linux
PHP version:      5.3.3
Package:          Strings related
Bug Type:         Bug
Bug description:Strip_tags() may strip '<br />' incorrectly

Description:
------------
---
From manual page: http://www.php.net/function.strip-tags#Return
Values
---


Test script:
---------------
<?php // RAY_strip_tags_anomaly.php
error_reporting(E_ALL);

// SELF-CLOSING TAGS WITH SPACES
$str = '<td>USD<br /><br />CDN</td>';
$new = strip_tags($str);
echo $new; // Prints USDCDN

// TRY TO PRESERVE ALLOWABLE TAGS
$new = strip_tags($str, '<br />');
echo $new; // Prints USDCDN -- The break tag is not preserved

$new = strip_tags($str, '<br>');
echo $new; // Prints USD<br /><br />CDN

// SELF-CLOSING TAGS WITHOUT SPACES
$str = '<td>USD<br/><br/>CDN</td>';
$new = strip_tags($str, '<br/>');
echo $new; // Prints USD<br/><br/>CDN


Expected result:
----------------
strip_tags() should preserve the allowable_tags

Actual result:
--------------
strip_tags did not always preserve the allowable_tags

-- 
Edit bug report at http://bugs.php.net/bug.php?id=53319&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=53319&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=53319&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=53319&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=53319&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53319&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=53319&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=53319&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=53319&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=53319&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=53319&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=53319&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=53319&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=53319&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=53319&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53319&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53319&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=53319&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=53319&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=53319&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=53319&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=53319&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#156069) next »