From: stas at metalinfo dot ru
Operating system: Debian Lenny
PHP version: 5.2.10
PHP Bug Type: Regexps related
Bug description: encoding problems with preg_replace
Description:
------------
preg_replace changes replaced string encoding when replacement parameter
is double quoted.
Reproduce code:
---------------
$source = 'asdfasd asdf asdf [company=456[replacement]] asdf';
echo preg_replace('~\[\s*company=([0-9]+)\[\s*([^\]]+\s*)\]\]~', '\2',
$source);
echo preg_replace('~\[\s*company=([0-9]+)\[\s*([^\]]+\s*)\]\]~', "\2",
$source);
Expected result:
----------------
asdfasd asdf asdf replacement asdf
asdfasd asdf asdf replacement asdf
Actual result:
--------------
asdfasd asdf asdf replacement asdf
asdfasd asdf asdf asdf
--
Edit bug report at http://bugs.php.net/?id=49508&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=49508&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=49508&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=49508&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=49508&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=49508&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=49508&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=49508&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=49508&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=49508&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=49508&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=49508&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=49508&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=49508&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=49508&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49508&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49508&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=49508&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=49508&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=49508&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=49508&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=49508&r=mysqlcfg