From:             [EMAIL PROTECTED]
Operating system: windows 98 / debian linux
PHP version:      4.0.4pl1
PHP Bug Type:     *Regular Expressions
Bug description:  eregi() crashes or runs terrible slow

I have an own e-mail source parser script for an archive engine. It has been working 
for a long time without errors, but it was crashed yesterday.
I have found the problem: eregi() halts with a 13k long text. This is same with PHP 
4.0.3 Windows and PHP 4.0.4pl Debian Linux.

I include a short script to show it:

--------
<?php

  $cuts = array("_______________________________________________\n");

  $lines = file('\work\mail.txt');
  foreach ($lines as $l) {
    $text .= $l . "\n";
  }
  $text = str_replace(chr(13),'',$text);
  echo strlen($text) . "\n\n";

  foreach ($cuts as $c) {
    $ok = true;
    $cnt = 0;
    while ($ok && $cnt < 15) {
      echo $c . "\n";
      $regs[2] = '';
      eregi("(.*)($c)(.*)",$text,$regs);
      $text = $regs[1] . $regs[3];
      $ok = ($regs[2] == $c) && ($c != ''); // originally it was "$ok = $regs[2]", but 
I was trying to find the problem so I have changed
      $cnt++;
      echo strlen($text) . "\n\n";
    }
  }

?>

----------

This is the  result with windows/php4.0.3:
"
13238

_______________________________________________

13190

_______________________________________________

<br>
<b>Fatal error</b>:  Maximum execution time of 30 seconds exceeded in 
<b>C:\Webroot\test\eregi\test.php4</b> on line <b>19</b><br>
"
----
The result with PHP 4.0.4pl - Debian
"
13239

_______________________________________________

13191

_______________________________________________

13143

_______________________________________________

<br>
<b>Fatal error</b>:  Maximum execution time of 180 seconds exceeded in 
<b>/home/mage/public_html/test/test.php4</b> on line <b>18</b><br>
"
------

I think this is a bug, but that happend only with a specific text file. I should send 
it.


-- 
Edit Bug report at: http://bugs.php.net/?id=9321&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to