php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5545 regular expression matching goes into almost infinite loop
Submitted: 2000-07-13 01:03 UTC Modified: 2000-07-13 03:28 UTC
From: elkan at cs dot ucsd dot edu Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 2 OS: Mandrake Linux 7.0r2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: elkan at cs dot ucsd dot edu
New email:
PHP Version: OS:

 

 [2000-07-13 01:03 UTC] elkan at cs dot ucsd dot edu
I am using 4.0.0 with Apache 1.3.12 and MySQL, all standard.
The following code works fine:

	$tpattern = ".*<big><b>(.*)</b></big>";
        if (eregi($tpattern,$text,$match)) {
                 $title = $match[1];

But adding .* at the end of the pattern, making

	$tpattern = ".*<big><b>(.*)</b></big>.*";

can take 41 seconds to run, measured using time().
Sometimes it gives the error message
	Fatal error: Maximum execution time of 30 seconds
	exceeded in /home/elkan/public_html/crawler.php on 		line 58	

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-13 03:28 UTC] stas at cvs dot php dot net
This is not a bug. You are just forcing regexp working too hard. Please take a good book on regular experssions (like Mastering Regular Experssions) and read about backtracking and how bad could it be.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 20:00:02 2026 UTC