Fix test failures in engine_unsafe_empty_string.phpt (#18727)

`/./` matches all characters but newlines, so if `random_bytes`
generates a string with newlines in it, the resulting string is not
empty. Fix this by adding the `s` modifier.
This commit is contained in:
Niels Dossche 2025-06-01 15:45:36 +02:00 committed by GitHub
parent d39d261b7e
commit d8a17ca7c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,7 @@ final class EmptyStringEngine implements Engine
public function generate(): string
{
// Create a non-interned empty string.
return preg_replace('/./', '', random_bytes(4));
return preg_replace('/./s', '', random_bytes(4));
}
}