|
14 | 14 | */
|
15 | 15 | abstract class Value implements Renderable
|
16 | 16 | {
|
17 |
| - const PARSE_TERMINATE_STRINGS = ['}',';','!',')', '\\']; |
18 |
| - const PARSE_QUOTE_STRINGS = ['"', "'", '\"', "\'"]; |
19 |
| - |
20 | 17 | /**
|
21 | 18 | * @var int
|
22 | 19 | */
|
@@ -44,8 +41,13 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
|
44 | 41 | $aStack = [];
|
45 | 42 | $oParserState->consumeWhiteSpace();
|
46 | 43 | //Build a list of delimiters and parsed values
|
47 |
| - while (self::continueParsing($oParserState)) { |
48 |
| - if (count($aStack) > 0) { |
| 44 | + while ( |
| 45 | + !($oParserState->comes('}') || $oParserState->comes(';') || $oParserState->comes('!') |
| 46 | + || $oParserState->comes(')') |
| 47 | + || $oParserState->comes('\\') |
| 48 | + || $oParserState->isEnd()) |
| 49 | + ) { |
| 50 | + if (\count($aStack) > 0) { |
49 | 51 | $bFoundDelimiter = false;
|
50 | 52 | foreach ($aListDelimiters as $sDelimiter) {
|
51 | 53 | if ($oParserState->comes($sDelimiter)) {
|
@@ -154,10 +156,7 @@ public static function parsePrimitiveValue(ParserState $oParserState)
|
154 | 156 | $oValue = Size::parse($oParserState);
|
155 | 157 | } elseif ($oParserState->comes('#') || $oParserState->comes('rgb', true) || $oParserState->comes('hsl', true)) {
|
156 | 158 | $oValue = Color::parse($oParserState);
|
157 |
| - } elseif ( |
158 |
| - in_array($oParserState->peek(), self::PARSE_QUOTE_STRINGS) |
159 |
| - || in_array($oParserState->peek(2), self::PARSE_QUOTE_STRINGS) |
160 |
| - ) { |
| 159 | + } elseif ($oParserState->comes("'") || $oParserState->comes('"')) { |
161 | 160 | $oValue = CSSString::parse($oParserState);
|
162 | 161 | } elseif ($oParserState->comes('progid:') && $oParserState->getSettings()->bLenientParsing) {
|
163 | 162 | $oValue = self::parseMicrosoftFilter($oParserState);
|
@@ -219,22 +218,4 @@ public function getLineNo()
|
219 | 218 | {
|
220 | 219 | return $this->iLineNo;
|
221 | 220 | }
|
222 |
| - |
223 |
| - /** |
224 |
| - * @return bool |
225 |
| - * |
226 |
| - * @throws UnexpectedEOFException |
227 |
| - * @throws UnexpectedTokenException |
228 |
| - */ |
229 |
| - private static function continueParsing(ParserState $oParserState) |
230 |
| - { |
231 |
| - if ($oParserState->isEnd()) { |
232 |
| - return false; |
233 |
| - } |
234 |
| - $sPeekOne = $oParserState->peek(); |
235 |
| - if ($sPeekOne === '\\') { |
236 |
| - return in_array($oParserState->peek(2), self::PARSE_QUOTE_STRINGS); |
237 |
| - } |
238 |
| - return !in_array($sPeekOne, self::PARSE_TERMINATE_STRINGS); |
239 |
| - } |
240 | 221 | }
|
0 commit comments