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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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 15:00:01 2026 UTC