php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36437 preg_replace
Submitted: 2006-02-18 02:34 UTC Modified: 2006-02-26 01:00 UTC
From: shahir_reza2001 at yahoo dot com Assigned:
Status: No Feedback Package: PHP options/info functions
PHP Version: 5.1.2 OS: FreeBSD 4.11
Private report: No CVE-ID: None
 [2006-02-18 02:34 UTC] shahir_reza2001 at yahoo dot com
Description:
------------
Preg_replace wont replace properly

Reproduce code:
---------------
 $patterns = '{([\w_]+)(\s*</font>)'.  
3	                        '(\s*<font\s+color="'.$keycol.'">\s*\()}m';  
4	           $replacements = '<a class="code" title="View manual page for $1" href="'.$manual.'$1" target="_blank">$1</a>$2$3'; 
5	           return  preg_replace($patterns, $replacements, $code); 

example using php4+:
downlaod any file from http://www.codedb.org/files.php?lang=php
and it will underline the add <a href> to the php functions


Expected result:
----------------
<br /></font><font color="#007700">function&nbsp;</font><font color="#0000BB"><a class="code" href="http://www.php.net/manual-lookup.php?lang=en&amp;pattern=isemail" title="View manual page for isemail" target="_blank">isemail</a></font><font color="#007700">(</font><font color="#0000BB">$mail</font><font color="#007700">)

<br />{
<br />&nbsp;&nbsp;if&nbsp;(</font><font color="#0000BB"><a class="code" href="http://www.php.net/manual-lookup.php?lang=en&amp;pattern=eregi" title="View manual page for eregi" target="_blank">eregi</a></font><font color="#007700">(</font><font color="#DD0000">"^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$"</font><font color="#007700">,</font><font color="#0000BB">$mail</font><font color="#007700">))
<br />&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</font><font color="#0000BB">1</font><font color="#007700">;
<br />&nbsp;&nbsp;}
<br />&nbsp;&nbsp;else&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</font><font color="#0000BB">0</font><font color="#007700">;

<br />&nbsp;&nbsp;}
<br />}
<br /></font><font color="#0000BB">?&gt;</font>

Actual result:
--------------
<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">isemail</span><span style="color: #007700">(</span><span style="color: #0000BB">$mail</span><span style="color: #007700">)

<br />{
<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">eregi</span><span style="color: #007700">(</span><span style="color: #DD0000">"^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$"</span><span style="color: #007700">,</span><span style="color: #0000BB">$mail</span><span style="color: #007700">))
<br />&nbsp;&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;
<br />&nbsp;&nbsp;}
<br />&nbsp;&nbsp;else&nbsp;{
<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;

<br />&nbsp;&nbsp;}
<br />}
<br /></span><span style="color: #0000BB">?&gt;</span>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-18 16:27 UTC] mike@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2006-02-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 01:01:28 2024 UTC