Regex with optional capture groups might cause catastrophic backtracking (#2490)

* fix catastrophic backtracking

* prevented catasthropic backtracing

Co-authored-by: David Moškoř <david.moskor@apertia.cz>
This commit is contained in:
David
2022-11-02 07:56:00 +01:00
committed by GitHub
parent 64b3328916
commit 042c5e5791
+1 -2
View File
@@ -215,8 +215,7 @@ class ErrorOutput
private function clearPasswords(string $string): string
{
/** @var string */
return preg_replace('/"(.*?password.*?)":".*?"/i', '"$1":"*****"', $string);
return preg_replace('/"(.*password.*)":".*"/i', '"$1":"*****"', $string) ?? $string;
}
private static function generateErrorBody(string $header, string $text): string