php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29486 / causes preg_replace troubles
Submitted: 2004-08-02 01:18 UTC Modified: 2004-08-02 01:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: slunta at msn dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.8 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: slunta at msn dot com
New email:
PHP Version: OS:

 

 [2004-08-02 01:18 UTC] slunta at msn dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-02 01:21 UTC] slunta at msn dot com
Please ignore the hyperlinks in the preg_replace code that was automatically created by this bug report page. Treat them as plain text.
 [2004-08-02 01:24 UTC] slunta at msn dot com
Sorry, I got it to work now. It was a modifyer issue >_>. Bug bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 15:01:28 2024 UTC