php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38597 preg_match with long match returns blanc page
Submitted: 2006-08-25 19:59 UTC Modified: 2006-08-25 20:35 UTC
From: koen dot devreeze at gmail dot com Assigned:
Status: Closed Package: PCRE related
PHP Version: 5.1.5 OS: Windows XP
Private report: No CVE-ID: None
 [2006-08-25 19:59 UTC] koen dot devreeze at gmail dot com
Description:
------------
When processing this code. The parsing ends on the preg_match function.
$t has 475 characters in it. Remove one char and the script works again.

PS.: This was also tested with php 5.1.4 on gentoo linux without any problems.

Reproduce code:
---------------
$t = "---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------";
$text = "
<p>".$t."</p>

<p>Some text doesn't matter how long</p>
";

//echo strlen($t);
	$pattern = '/<p([a-z "=]*)?>((.)*?)<(\/)?p>/';
	preg_match($pattern, $text, $paragraphs) or die("died");

echo $paragraphs[0];

Expected result:
----------------
$t should be displayed no matter how many chars it has (though considering limitation of PCRE).

Actual result:
--------------
Script ends on preg_match after a few seconds of 100% CPU load. No errors no crashes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-25 20:21 UTC] edink@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-08-25 20:33 UTC] koen dot devreeze at gmail dot com
The problem is fixed in cvs snapshot of php 5.2.
Thanks.
 [2006-08-25 20:35 UTC] koen dot devreeze at gmail dot com
Closing bug report
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 02:01:24 2019 UTC