Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003296 [Quercus] minor always 01-24-09 16:36 01-26-09 12:14
Reporter koreth View Status public  
Assigned To nam
Priority normal Resolution fixed  
Status closed   Product Version 4.0.0
Summary 0003296: preg_replace throws exception on malformed UTF-8 when "u" modifier is used
Description <?php
$bad_utf8 = "abc\xf0";
print strlen(preg_replace("/[^\pL]/u", "", $bad_utf8));

Regular PHP prints "0" (the preg_replace returns an empty string). Quercus throws an exception:

com.caucho.quercus.QuercusRuntimeException: bad UTF-8 sequence, saw EOF
    at com.caucho.quercus.lib.regexp.Regexp.fromUtf8(Regexp.java:267)
    at com.caucho.quercus.lib.regexp.Regexp.convertSubject(Regexp.java:182)
    at com.caucho.quercus.lib.regexp.RegexpState.<init>(RegexpState.java:79)
    at com.caucho.quercus.lib.regexp.CauchoRegexpModule.pregReplaceString(CauchoRegexpModule.java:769)
    at com.caucho.quercus.lib.regexp.CauchoRegexpModule.pregReplace(CauchoRegexpModule.java:678)
    at com.caucho.quercus.lib.regexp.CauchoRegexpModule.preg_replace(CauchoRegexpModule.java:614)
    at com.caucho.quercus.lib.regexp.RegexpModule.preg_replace(RegexpModule.java:175)

Workaround is to sanitize the input before calling preg_replace.
Additional Information
Attached Files

- Relationships

- Notes
(0003779)
nam
01-26-09 12:14

php/153k
 

- Issue History
Date Modified Username Field Change
01-24-09 16:36 koreth New Issue
01-24-09 20:59 nam Status new => assigned
01-24-09 20:59 nam Assigned To  => nam
01-26-09 12:14 nam Status assigned => closed
01-26-09 12:14 nam Note Added: 0003779
01-26-09 12:14 nam Resolution open => fixed
01-26-09 12:14 nam Fixed in Version  => 4.0.0


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
29 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker