Skip to content

Commit adc65af

Browse files
committed
Use the preg_match_all return to detect failures
Even if we cannot match anything we would have had an array containing an empty array. That array indicates that nothing was matched. We should now fail when: - preg_match_all fails - preg_match_all returns it found 0 matches - the redundant case (as safeguard) when the array has 0 matches (cherry picked from commit 274d36a)
1 parent 1ba02e7 commit adc65af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

webapp/src/Twig/TwigExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,8 @@ public function hexColorToRGBA(string $text, float $opacity = 1): string
10321032
if (is_null($col)) {
10331033
return $text;
10341034
}
1035-
preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m);
1036-
if (!count($m)) {
1035+
$ret = preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m);
1036+
if (!($ret && count($m[0]))) {
10371037
return $text;
10381038
}
10391039

0 commit comments

Comments
 (0)