Skip to content

Commit c1929d4

Browse files
authored
[BUGFIX] Use safe preg functions in Value (#1379)
Also use typesafe comparisons in the affected line. Part of #1168
1 parent 629d380 commit c1929d4

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Please also have a look at our
1818

1919
### Fixed
2020

21+
- Use typesafe versions of PHP functions (#1379)
22+
2123
### Documentation
2224

2325
## 9.1.0: Add support for PHP 8.5

src/Value/Value.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Sabberworm\CSS\Position\Position;
1313
use Sabberworm\CSS\Position\Positionable;
1414

15+
use function Safe\preg_match;
16+
1517
/**
1618
* Abstract base class for specific classes of CSS values: `Size`, `Color`, `CSSString` and `URL`, and another
1719
* abstract subclass `ValueList`.
@@ -204,7 +206,9 @@ private static function parseUnicodeRangeValue(ParserState $parserState): string
204206
$codepointMaxLength = 13; // Max length is 2 six-digit code points + the dash(-) between them
205207
}
206208
$range .= $parserState->consume(1);
207-
} while (\strlen($range) < $codepointMaxLength && \preg_match('/[A-Fa-f0-9\\?-]/', $parserState->peek()));
209+
} while (
210+
(\strlen($range) < $codepointMaxLength) && (preg_match('/[A-Fa-f0-9\\?-]/', $parserState->peek()) === 1)
211+
);
208212

209213
return "U+{$range}";
210214
}

0 commit comments

Comments
 (0)