From:             tokie at hanmail dot net
Operating system: Linux 2.4.x (Fedora core 1)
PHP version:      5.0.0b4 (beta4)
PHP Bug Type:     POSIX related
Bug description:  ereg_replace working weird with hexadeciaml escape code

Description:
------------
I was handling some broken text file. And I managed to fix it by replacing
the ascii-control characters (0x00 to 0x1F) to avoid crash when INSERT the
text into a db-table.



But the ereg_replace replaces other critical characters such as 0-9 : < =
> ... (seems to be 0x30 to 0x3F), too.



Reproduce code:
---------------
$str = "<a href='http://www.php.net/'>PHP.net</a>";

$result = ereg_replace("[\\x00-\\x1F]", "*", $str);



// the result was: 

// *a href*'http*//www.php.net/'*PHP.net*/a*

// not,

// <a href='http://www.php.net/'>PHP.net</a>



Expected result:
----------------
the function should replace only the characters ranging 0x00 ~ 0x1F only.

Actual result:
--------------
it replaced not only 0x00 - 0x1F but also 0x30 ~ 0x3F (I guess, and 0x20 ~
0x2F seems to be safe)

-- 
Edit bug report at http://bugs.php.net/?id=27257&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27257&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27257&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27257&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27257&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27257&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27257&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27257&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27257&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27257&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27257&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27257&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27257&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27257&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27257&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27257&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27257&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27257&r=float

Reply via email to