ID:               28886
 User updated by:  slunta at msn dot com
 Reported By:      slunta at msn dot com
 Status:           Open
 Bug Type:         Output Control
 Operating System: Linux
 PHP Version:      4.3.6
 New Comment:

It's either \n or <br /> causing this issue: I am not sure.


Previous Comments:
------------------------------------------------------------------------

[2004-06-23 04:40:49] slunta at msn dot com

Description:
------------
I don't know why, or how, but it appears that a line break in a
textarea will cause a preg_replace to quit. Let me show you the code
and the page so you can test it and see for yourself what I'm talking
about.

You can find the page with the code at:

http://turkeybot.olddh.com/bug.php

Reproduce code:
---------------
<?

$message=isset($_POST['message']) ? htmlentities($_POST['message'])
:'';

$array1=array('/&lt;b&gt;(.+)&lt;\/b&gt;/','/&lt;i&gt;(.+)&lt;\/i&gt;/','/&lt;u&gt;(.+)&lt;\/u&gt;/');
$array2=array('<b>$1</b>','<i>$1</i>','<u>$1</u>');
$mess=preg_replace($array1,$array2,$message);

echo '<html>
<form action="bug.php" method="post">
' .$mess. '
<textarea name="message" cols="40" rows="10"></textarea>
<input type="submit" name="post" value="Post" /><input type="reset"
name="reset" value="Reset" /></form>';

?>

Expected result:
----------------
When I post the data, I always expect to see my <b>,<i>,and<u> tags to
run correctly and display the message with the proper html.

Actual result:
--------------
The preg_replace fails in replacing the entities with the proper tags
once a line break is inserted into the textarea.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28886&edit=1

Reply via email to