#28886 [Opn->Bgs]: line breaks in textareas forces preg_replace to quit
| From: | iliaa@php.net | Date: | Thu, 24 Jun 2004 00:42:29 +0000 |
| Subject: | #28886 [Opn->Bgs]: line breaks in textareas forces preg_replace to quit | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-61230@lists.php.net to get a copy of this message | ||
ID: 28886
Updated by: iliaa@php.net
Reported By: slunta at msn dot com
-Status: Open
+Status: Bogus
Bug Type: Output Control
Operating System: Linux
PHP Version: 4.3.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You need to specify a parameter that will tell preg_* not
to stop at a new line.
Previous Comments:
------------------------------------------------------------------------
[2004-06-23 04:43:15] slunta at msn dot com
It's either \n or <br /> causing this issue: I am not sure.
------------------------------------------------------------------------
[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('/<b>(.+)<\/b>/','/<i>(.+)<\/i>/','/<u>(.+)<\/u>/');
$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