From: victor at casnt dot ro
Operating system: Debian
PHP version: 5.2.8
PHP Bug Type: Regexps related
Bug description: pattern matching is not working as expected
Description:
------------
The exact same pattern matching is not working on the same string, with a
extra line at the end.
The length of the string seems to be the problem.
Reproduce code:
---------------
The script:
$handle = fopen('test3.xml', "r");
$contents = fread($handle, filesize('test3.xml'));
fclose($handle);
$contents = preg_replace('/\>[\t|\ |\s]{1,}\</', "><", $contents);
$contents = preg_replace('/\n/', "", $contents);
if(preg_match('/(\<\?xml.{1,}\<report[^>]{1,}\>)/', $contents, $match)) {
print "Match: $match[1]\n";
} else {print "Fail\n";}
OBSERVATION: If you delete the last line from the file test3.xml, the
pattern matching will work fine. The last lines have nothing to do with the
pattern.
You can find the file here:
http://www.casnt.ro/Files/XML/test3.xml
Expected result:
----------------
Match: <?xml version="1.0" encoding="utf-8"?><report
AppKey="CNAS-v1.0.2801.665" AppID="14" clinic="SSSSSSSSSSSSSSSSSSSSSS"
fiscalCode="11111111" contractNo="123123123/2008" insuranceHouse="CAS-NT"
reportingDate="2008-12-07" startFrom="2008-11-01" endTo="2008-11-30"
invoiceNo="" labValue="0" hspValue="0" xmlns="http://localhost">
Actual result:
--------------
Fail
--
Edit bug report at http://bugs.php.net/?id=46947&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46947&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46947&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46947&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=46947&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=46947&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=46947&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=46947&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=46947&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=46947&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=46947&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=46947&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46947&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46947&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=46947&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46947&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46947&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=46947&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=46947&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=46947&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=46947&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=46947&r=mysqlcfg