From: slunta at msn dot com Operating system: Linux PHP version: 4.3.8 PHP Bug Type: Output Control Bug description: / causes preg_replace troubles
Description: ------------ I don't know why, but a / right before a wildcard is causing a preg replace to stop. I don't believe it's a modifier issue either. Reproduce code: --------------- $message=isset($_POST['message']) ? htmlentities(trim($_POST['message'])) :''; $array1=array(); $array2=array(); $array1[]='/http:\/\/' . $_SERVER['HTTP_HOST'] . '\/(.*)/'; $array2[]='<a href="http://' . $_SERVER['HTTP_HOST'] . '/$1">http://' . $_SERVER['HTTP_HOST'] . '/$1</a>'; $output=preg_replace($array1,$array2,$message); Expected result: ---------------- In my case, the http host is turkeybot.olddh.com, and I post http://turkeybot.olddh.com/downloads/index.php. The output is expected to be: <a href="http://turkeybot.olddh.com/downloads/index.php">http://turkeybot.olddh.com/downloads/index.php</a> Actual result: -------------- The output I'm really getting is: <a href="http://turkeybot.olddh.com/">http://turkeybot.olddh.com/</a>downloads/index.php -- Edit bug report at http://bugs.php.net/?id=29486&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29486&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29486&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29486&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29486&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29486&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29486&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29486&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29486&r=support Expected behavior: http://bugs.php.net/fix.php?id=29486&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29486&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29486&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29486&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29486&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29486&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29486&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29486&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29486&r=float