[php-src] Issue #9762: In last update 7.4.30->7.4.32 strange bug in preg_replace
| From: | partizanes | Date: | Mon, 17 Oct 2022 11:09:58 +0000 |
| Subject: | [php-src] Issue #9762: In last update 7.4.30->7.4.32 strange bug in preg_replace | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242613@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9762
Author: partizanes
### Description
The following code after update to 7.4.32 from 7.4.30:
```php
<?php
$file = DIR_APPLICATION . 'controller/' . $this->route . '.php';
$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '',
$this->route);
if (is_file($file)) {
include_once(modification($file));
$controller = new $class($registry);
```
Resulted in this output:
```
I got error PHP Fatal error: Uncaught Error: Class 'Controllerstartup' not found in
/user/public_html/system/storage/modification/system/engine/action.php:43
for debug i add this line
file_put_contents('./log_test.log', $this->route.PHP_EOL, FILE_APPEND);
file_put_contents('./log_test.log', $class.PHP_EOL, FILE_APPEND);
and check output with show unprintable symbol:
# tail -f ./log_test.log | cat -v
startup/session
Controllerstartup^@^@^@session
As you can see, as a result of the replacement, non-printable characters appeared that lead to the
above error.
```
But I expected this output instead:
```
When i downgrade to 7.4.30 i got
startup/session
Controllerstartupsession
and all working.
```
I tried to check this behavior in a separate script by replacing $this->route with a string, but
it was not possible to repeat this behavior there. Any help?
### PHP Version
PHP 7.4.32
### Operating System
CloudLinux