[php-src] Issue #12885: preg_replace times out after upgrading to 8.2 when browscap setting is set
| From: | ymTm7KuhCnIjkZAl2x2m2 | Date: | Wed, 06 Dec 2023 19:03:40 +0000 |
| Subject: | [php-src] Issue #12885: preg_replace times out after upgrading to 8.2 when browscap setting is set | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246000@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12885
Author: ymTm7KuhCnIjkZAl2x2m2
### Description
I had this issue after upgrading to 8.2 and I've created this example that shows the issue. My
php.ini is exactly the production version with one change: browscap points to the latest
lite_php_browscap.ini from browscap.org. I'm using IIS on Windows Server 2022.
The following code:
```php
<?php
$string = 'The quick brown fox jumps over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[0] = 'slow';
$replacements[1] = 'black';
$replacements[2] = 'bear';
echo preg_replace($patterns, $replacements, $string);
```
Resulted in this output:
```
HTTP Error 500.0 - Internal Server Error
```
But I expected this output instead:
```
The slow bear jumps over the lazy dog.
```
In fact, I do get this output if I comment out the browscap setting in php.ini. I also get this
result if I remove many lines from the browscap file. I did not see this issue in PHP 8.1.
### PHP Version
8.2.13
### Operating System
Windows Server 2022