Part of the EllisLab Network
   
 
Bug for PHP 5.2
Posted: 14 December 2006 08:32 AM   [ Ignore ]  
Summer Student
Total Posts:  1
Joined  07-27-2006

Hi,

Here is a bug I discovered for PHP 5.2.
In this new version, the preg_replace does not seems to work properly.

Depending on the pattern and on the subject, it may return null rather than the unmodified string in case of no match.
It at least impact the Input.php file.

The result of this bug is that function xss_clean returns an empty string in some cases rather than the correct value.
I just created a function _safe_preg_replace, that takes the same parameters as the original functionand which simply check for the result.

/**
* This function is called in order to produce a safe preg_replace managing the PHP 5.2 bug
*
* @param unknown_type $pattern
* @param unknown_type $replacment
* @param unknown_type $source
*/
function _safe_preg_replace( $pattern, $replacment, $source )
{
    $temp
= preg_replace($pattern,$replacment,$source);
    return (
$temp==null)?$source:$temp;        
}

I just replace the preg_replace call by this new function so that my argument is no more trashed.
I hope it will help.

Arnaud

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66413 Total Logged-in Users: 32
Total Topics: 84753 Total Anonymous Users: 0
Total Replies: 454832 Total Guests: 232
Total Posts: 539585    
Members ( View Memberlist )
Newest Members:  byrooNirCalexmuellerkizerdrixcaptainredmuffquinodligtharttechsivamDjordjesammozza