File tree Expand file tree Collapse file tree 1 file changed +6
-18
lines changed Expand file tree Collapse file tree 1 file changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -37,27 +37,15 @@ public static function parse(ParserState $oParserState, $bIsColorComponent = fal
3737 }
3838 }
3939
40- $ sParsedUnit = '' ;
41- $ iOffset = 0 ;
42- while (true ) {
43- $ sChar = $ oParserState ->peek (1 , $ iOffset );
44- $ iPeek = ord ($ sChar );
45-
46- // Ranges: a-z A-Z 0-9 %
47- if (($ iPeek >= 97 && $ iPeek <= 122 ) ||
48- ($ iPeek >= 65 && $ iPeek <= 90 ) ||
49- ($ iPeek >= 48 && $ iPeek <= 57 ) ||
50- ($ iPeek === 37 )) {
51- $ sParsedUnit .= $ sChar ;
52- $ iOffset ++;
53- } else {
54- break ;
55- }
56- }
57-
5840 $ sUnit = null ;
41+ $ sParsedUnit = null ;
5942 $ aSizeUnits = self ::getSizeUnits ();
6043
44+ $ iMaxSizeUnitLength = max (array_keys ($ aSizeUnits ));
45+ if ( preg_match ( '/^[a-zA-Z0-9%]+/ ' , $ oParserState ->peek ($ iMaxSizeUnitLength ), $ matches ) ) {
46+ $ sParsedUnit = $ matches [0 ];
47+ }
48+
6149 foreach ($ aSizeUnits as $ iLength => $ aValues ) {
6250 $ sKey = strtolower ($ oParserState ->peek ($ iLength ));
6351 if (array_key_exists ($ sKey , $ aValues )) {
You can’t perform that action at this time.
0 commit comments