Skip to content

Commit 274d36a

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
1 parent 11d2169 commit 274d36a

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
@@ -1023,8 +1023,8 @@ public function hexColorToRGBA(string $text, float $opacity = 1): string
10231023
if (is_null($col)) {
10241024
return $text;
10251025
}
1026-
preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m);
1027-
if (!count($m)) {
1026+
$ret = preg_match_all("/[0-9A-Fa-f]{2}/", $col, $m);
1027+
if (!($ret && count($m[0]))) {
10281028
return $text;
10291029
}
10301030

0 commit comments

Comments
 (0)