MDL-58646 lib: import latest sabberworm/PHP-CSS-Parser
authorDan Poltawski <dan@moodle.com>
Fri, 2 Jun 2017 06:36:40 +0000 (07:36 +0100)
committerDan Poltawski <dan@moodle.com>
Fri, 2 Jun 2017 06:45:57 +0000 (07:45 +0100)
This version includes a fix[1] contributed by Frédéric Massart investigating
our compilation time issues, which significantly improves the speed of
processing font awesome.

Thanks, Fred!

[1] https://github.com/sabberworm/PHP-CSS-Parser/pull/120

lib/php-css-parser/Parser.php
lib/php-css-parser/moodle_readme.txt

index 409b796..65ea2f0 100644 (file)
@@ -265,7 +265,7 @@ class Parser {
                        if (preg_match('/[0-9a-fA-F]/Su', $this->peek()) === 0) {
                                return $this->consume(1);
                        }
                        if (preg_match('/[0-9a-fA-F]/Su', $this->peek()) === 0) {
                                return $this->consume(1);
                        }
-                       $sUnicode = $this->consumeExpression('/^[0-9a-fA-F]{1,6}/u');
+                       $sUnicode = $this->consumeExpression('/^[0-9a-fA-F]{1,6}/u', 6);
                        if ($this->strlen($sUnicode) < 6) {
                                //Consume whitespace after incomplete unicode escape
                                if (preg_match('/\\s/isSu', $this->peek())) {
                        if ($this->strlen($sUnicode) < 6) {
                                //Consume whitespace after incomplete unicode escape
                                if (preg_match('/\\s/isSu', $this->peek())) {
@@ -565,9 +565,10 @@ class Parser {
                }
        }
 
                }
        }
 
-       private function consumeExpression($mExpression) {
+       private function consumeExpression($mExpression, $iMaxLength = null) {
                $aMatches = null;
                $aMatches = null;
-               if (preg_match($mExpression, $this->inputLeft(), $aMatches, PREG_OFFSET_CAPTURE) === 1) {
+               $sInput = $iMaxLength !== null ? $this->peek($iMaxLength) : $this->inputLeft();
+               if (preg_match($mExpression, $sInput, $aMatches, PREG_OFFSET_CAPTURE) === 1) {
                        return $this->consume($aMatches[0][0]);
                }
                throw new UnexpectedTokenException($mExpression, $this->peek(5), 'expression', $this->iLineNo);
                        return $this->consume($aMatches[0][0]);
                }
                throw new UnexpectedTokenException($mExpression, $this->peek(5), 'expression', $this->iLineNo);
index 16b02e2..f63dd81 100644 (file)
@@ -1,7 +1,7 @@
 PHP CSS Parser
 --------------
 
 PHP CSS Parser
 --------------
 
-Import git ref: 50a802f562e71236140e2a8903b097c28d6101de
+Import git ref: c3b01ef0a85824e86fd86a74a8154d8d5c34b0ff
                 (master)
 
 Downloaded from: https://github.com/sabberworm/PHP-CSS-Parser
                 (master)
 
 Downloaded from: https://github.com/sabberworm/PHP-CSS-Parser