From:
Operating system: Ubuntu LAMP
PHP version: 5.3.10
Package: PCRE related
Bug Type: Bug
Bug description:Corruption of "=0a" but not "=a0"
Description:
------------
Passing following UTF8 text thru 3rd line of the test script (i.e.,
preg_replace() function) causes an error in preg_replace function:
[post=0a /]
Whereas, passing following UTF8 text similarly causes no error:
[post=a0 /]
Problem seems to be caused only when the "=" is followed by an integer then
followed by a letter. I briefly tried other combinations without causing
error.
Workaround is to replace third line of test script with this line (i.e.,
use the
preg_replace_callback() instead of preg_replace()
$out = preg_replace_callback( '@\[p(?:ost){0,1}=(.{1,24})\ {0,}\/\]@Uiu',
'debdcode_post', $i_html );
Test script:
---------------
$html_ours[0] = '@\[p(?:ost){0,1}=(.{1,24})\ {0,}\/\]@Uieu';
$html_oursr[0] = 'debdcode_post( $1 )'; // irrelevant, use any misc func
that looks up post id in db
$out = preg_replace( $html_ours, $html_oursr, $i_html );
Expected result:
----------------
The general use is in a BBCODE-like parser for use in a FORUMS app.
What should happen:
In the source text (in UTF-8 format),
the string "[post=4ablahblah /]"
should be picked out of any given arbitrary input
by the preg_replace()
and then translated to a hyperlink
by the debdcode_post(). What is happening instead is the error in
preg_replace,
presumably from malformed UTF-8 or possibly a bug inside preg_replace when
dealing with the particular character sequence "=<integer><letter(s) and/or
integer(s)>. Note that it's the "=" followed by an integer and then
followed by
at least one letter and/or more integers that triggers the error. I hope
this
helps; thank you for looking.
Actual result:
--------------
Parse error: syntax error, unexpected T_STRING in
/apath/Class/common_functions.inc(1405) : regexp code on line 1
Fatal error: preg_replace() [<a
href='function.preg-replace'>function.preg-
replace</a>]: Failed evaluating code: debdcode_post(
4f30abfddc79595474000020 ) in
<file:line>
--
Edit bug report at https://bugs.php.net/bug.php?id=61001&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61001&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61001&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61001&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61001&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61001&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61001&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61001&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61001&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61001&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61001&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61001&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61001&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61001&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61001&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61001&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61001&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61001&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61001&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61001&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61001&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61001&r=mysqlcfg