diff --git a/Gruntfile.js b/Gruntfile.js index 2e783e75f04..c23f74d0512 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -25,7 +25,6 @@ module.exports = function( grunt ) { // ⚠️ Warning: These paths are passed straight to rm command in the shell, without any escaping. const productionVendorExcludedFilePatterns = [ 'composer.*', - 'patches', 'lib', 'vendor/*/*/.editorconfig', 'vendor/*/*/.git', @@ -164,7 +163,6 @@ module.exports = function( grunt ) { paths.push( 'assets/js/**/*.js' ); paths.push( 'assets/js/**/*.asset.php' ); paths.push( 'assets/css/*.css' ); - paths.push( 'patches/*.patch' ); if ( 'development' === process.env.NODE_ENV ) { paths.push( 'assets/js/**/*.js.map' ); diff --git a/composer.json b/composer.json index a56011dd6eb..c5193974038 100644 --- a/composer.json +++ b/composer.json @@ -56,9 +56,9 @@ }, "patches": { "sabberworm/php-css-parser": { - "Add additional validation for size unit ": "patches/php-css-parser-pull-193.patch", - "Validate name-start code points for identifier ": "patches/php-css-parser-pull-185.patch", - "Fix parsing CSS selectors which contain commas ": "patches/php-css-parser-commit-10a2501.patch" + "Add additional validation for size unit ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/3bc5ded67d77a52b81608cfc97f23b1bb0678e2f%5E...468da3441945e9c1bf402a3340b1d8326723f7d9.patch", + "Validate name-start code points for identifier ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/d42b64793f2edaffeb663c63e9de79069cdc0831%5E...113df5d55e94e21c6402021dfa959924941d4c29.patch", + "Fix parsing CSS selectors which contain commas ": "https://github.com/westonruter/PHP-CSS-Parser/compare/master...10a2501c119abafced3e4014aa3c0a3453a86f67.patch" } } }, diff --git a/composer.lock b/composer.lock index b3352ce9122..00faa693f53 100644 --- a/composer.lock +++ b/composer.lock @@ -4,11 +4,11 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "22ab1d8f28dd0e15d9cef2098b9d7f84", + "content-hash": "54a74199d32242f13b54ab0efae95acb", "packages": [ { "name": "ampproject/common", - "version": "dev-update-dependencies", + "version": "dev-enhancement/composer-remote-patches", "dist": { "type": "path", "url": "lib/common", @@ -86,7 +86,7 @@ }, { "name": "ampproject/optimizer", - "version": "dev-update-dependencies", + "version": "dev-enhancement/composer-remote-patches", "dist": { "type": "path", "url": "lib/optimizer", @@ -346,9 +346,9 @@ "type": "library", "extra": { "patches_applied": { - "Add additional validation for size unit ": "patches/php-css-parser-pull-193.patch", - "Validate name-start code points for identifier ": "patches/php-css-parser-pull-185.patch", - "Fix parsing CSS selectors which contain commas ": "patches/php-css-parser-commit-10a2501.patch" + "Add additional validation for size unit ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/3bc5ded67d77a52b81608cfc97f23b1bb0678e2f%5E...468da3441945e9c1bf402a3340b1d8326723f7d9.patch", + "Validate name-start code points for identifier ": "https://github.com/sabberworm/PHP-CSS-Parser/compare/d42b64793f2edaffeb663c63e9de79069cdc0831%5E...113df5d55e94e21c6402021dfa959924941d4c29.patch", + "Fix parsing CSS selectors which contain commas ": "https://github.com/westonruter/PHP-CSS-Parser/compare/master...10a2501c119abafced3e4014aa3c0a3453a86f67.patch" } }, "autoload": { @@ -719,16 +719,16 @@ }, { "name": "google/cloud-core", - "version": "v1.39.0", + "version": "v1.40.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-cloud-php-core.git", - "reference": "f9e7421beac89fd7d9006a13a6b39b89dd86c92e" + "reference": "1f45457d796c3807bc4b19c3d7b7e89a2f59d63c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/f9e7421beac89fd7d9006a13a6b39b89dd86c92e", - "reference": "f9e7421beac89fd7d9006a13a6b39b89dd86c92e", + "url": "https://api.github.com/repos/googleapis/google-cloud-php-core/zipball/1f45457d796c3807bc4b19c3d7b7e89a2f59d63c", + "reference": "1f45457d796c3807bc4b19c3d7b7e89a2f59d63c", "shasum": "" }, "require": { @@ -776,7 +776,7 @@ "Apache-2.0" ], "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", - "time": "2020-09-08T20:52:20+00:00" + "time": "2020-10-30T21:33:33+00:00" }, { "name": "google/cloud-storage", @@ -1959,12 +1959,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "327370943772f9917bc2dc2aa4263db2d572a112" + "reference": "065a018d3b5c2c84a53db3347cca4e1b7fa362a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/327370943772f9917bc2dc2aa4263db2d572a112", - "reference": "327370943772f9917bc2dc2aa4263db2d572a112", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/065a018d3b5c2c84a53db3347cca4e1b7fa362a6", + "reference": "065a018d3b5c2c84a53db3347cca4e1b7fa362a6", "shasum": "" }, "conflict": { @@ -1980,7 +1980,7 @@ "bagisto/bagisto": "<0.1.5", "barrelstrength/sprout-base-email": "<1.2.7", "barrelstrength/sprout-forms": "<3.9", - "baserproject/basercms": ">=4,<=4.3.6", + "baserproject/basercms": ">=4,<=4.3.6|>=4.4,<4.4.1", "bolt/bolt": "<3.7.1", "brightlocal/phpwhois": "<=4.2.5", "buddypress/buddypress": "<5.1.2", @@ -2064,7 +2064,7 @@ "magento/magento1ee": ">=1,<1.14.4.3", "magento/product-community-edition": ">=2,<2.2.10|>=2.3,<2.3.2-p.2", "marcwillmann/turn": "<0.3.3", - "mediawiki/core": ">=1.31,<1.31.4|>=1.32,<1.32.4|>=1.33,<1.33.1", + "mediawiki/core": ">=1.31,<1.31.9|>=1.32,<1.32.4|>=1.33,<1.33.3|>=1.34,<1.34.3|>=1.34.99,<1.35", "mittwald/typo3_forum": "<1.2.1", "monolog/monolog": ">=1.8,<1.12", "namshi/jose": "<2.2", @@ -2079,7 +2079,8 @@ "onelogin/php-saml": "<2.10.4", "oneup/uploader-bundle": "<1.9.3|>=2,<2.1.5", "openid/php-openid": "<2.3", - "openmage/magento-lts": "<19.4.6|>=20,<20.0.2", + "openmage/magento-lts": "<19.4.8|>=20,<20.0.4", + "orchid/platform": ">=9,<9.4.4", "oro/crm": ">=1.7,<1.7.4", "oro/platform": ">=1.7,<1.7.4", "padraic/humbug_get_contents": "<1.1.2", @@ -2114,8 +2115,8 @@ "scheb/two-factor-bundle": ">=0,<3.26|>=4,<4.11", "sensiolabs/connect": "<4.2.3", "serluck/phpwhois": "<=4.2.6", - "shopware/core": "<=6.3.1", - "shopware/platform": "<=6.3.1", + "shopware/core": "<=6.3.2", + "shopware/platform": "<=6.3.2", "shopware/shopware": "<5.3.7", "silverstripe/admin": ">=1.0.3,<1.0.4|>=1.1,<1.1.1", "silverstripe/assets": ">=1,<1.4.7|>=1.5,<1.5.2", @@ -2148,7 +2149,7 @@ "sylius/grid": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", "sylius/grid-bundle": ">=1,<1.1.19|>=1.2,<1.2.18|>=1.3,<1.3.13|>=1.4,<1.4.5|>=1.5,<1.5.1", "sylius/resource-bundle": "<1.3.14|>=1.4,<1.4.7|>=1.5,<1.5.2|>=1.6,<1.6.4", - "sylius/sylius": "<1.3.16|>=1.4,<1.4.12|>=1.5,<1.5.9|>=1.6,<1.6.5", + "sylius/sylius": "<1.6.9|>=1.7,<1.7.9|>=1.8,<1.8.3", "symbiote/silverstripe-multivaluefield": ">=3,<3.0.99", "symbiote/silverstripe-versionedfiles": "<=2.0.3", "symfony/cache": ">=3.1,<3.4.35|>=4,<4.2.12|>=4.3,<4.3.8", @@ -2261,7 +2262,7 @@ "type": "tidelift" } ], - "time": "2020-10-19T07:02:45+00:00" + "time": "2020-11-01T20:01:47+00:00" }, { "name": "sirbrillig/phpcs-variable-analysis", @@ -2829,16 +2830,16 @@ }, { "name": "wp-cli/extension-command", - "version": "v2.0.12", + "version": "v2.0.13", "source": { "type": "git", "url": "https://github.com/wp-cli/extension-command.git", - "reference": "ed5cd65d5ddef4ceda09fe8cf45986c9beeebbfe" + "reference": "2f97fee8f06c68187d052b89a2861bab7a57d833" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/ed5cd65d5ddef4ceda09fe8cf45986c9beeebbfe", - "reference": "ed5cd65d5ddef4ceda09fe8cf45986c9beeebbfe", + "url": "https://api.github.com/repos/wp-cli/extension-command/zipball/2f97fee8f06c68187d052b89a2861bab7a57d833", + "reference": "2f97fee8f06c68187d052b89a2861bab7a57d833", "shasum": "" }, "require": { @@ -2917,7 +2918,7 @@ ], "description": "Manages plugins and themes, including installs, activations, and updates.", "homepage": "https://github.com/wp-cli/extension-command", - "time": "2020-09-29T05:33:20+00:00" + "time": "2020-11-01T21:54:20+00:00" }, { "name": "wp-cli/mustangostang-spyc", @@ -3023,12 +3024,12 @@ "source": { "type": "git", "url": "https://github.com/wp-cli/wp-cli.git", - "reference": "b00716eb3d356a316538c026f5c5b920ff87c32c" + "reference": "b9e30a0299c94457e472e99f2f79422ce3bbcae7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/b00716eb3d356a316538c026f5c5b920ff87c32c", - "reference": "b00716eb3d356a316538c026f5c5b920ff87c32c", + "url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/b9e30a0299c94457e472e99f2f79422ce3bbcae7", + "reference": "b9e30a0299c94457e472e99f2f79422ce3bbcae7", "shasum": "" }, "require": { @@ -3081,7 +3082,7 @@ "cli", "wordpress" ], - "time": "2020-10-29T15:28:02+00:00" + "time": "2020-11-01T10:43:38+00:00" }, { "name": "wp-coding-standards/wpcs", diff --git a/patches/php-css-parser-commit-10a2501.patch b/patches/php-css-parser-commit-10a2501.patch deleted file mode 100644 index ca0f792c4b9..00000000000 --- a/patches/php-css-parser-commit-10a2501.patch +++ /dev/null @@ -1,143 +0,0 @@ -From fa139f65c5b098ae652c970b25e6eb03fc495eb4 Mon Sep 17 00:00:00 2001 -From: Weston Ruter -Date: Wed, 25 Jul 2018 10:38:59 -0700 -Subject: [PATCH 1/2] Fix parsing CSS selectors which contain commas - ---- - .../CSS/RuleSet/DeclarationBlock.php | 60 ++++++++++++++++++- - tests/Sabberworm/CSS/ParserTest.php | 6 ++ - tests/files/specificity.css | 4 +- - 3 files changed, 68 insertions(+), 2 deletions(-) - -diff --git a/lib/Sabberworm/CSS/RuleSet/DeclarationBlock.php b/lib/Sabberworm/CSS/RuleSet/DeclarationBlock.php -index e18f5d8..26c2e12 100644 ---- a/lib/Sabberworm/CSS/RuleSet/DeclarationBlock.php -+++ b/lib/Sabberworm/CSS/RuleSet/DeclarationBlock.php -@@ -28,7 +28,19 @@ public function setSelectors($mSelector) { - if (is_array($mSelector)) { - $this->aSelectors = $mSelector; - } else { -- $this->aSelectors = explode(',', $mSelector); -+ list( $sSelectors, $aPlaceholders ) = $this->addSelectorExpressionPlaceholders( $mSelector ); -+ if ( empty( $aPlaceholders ) ) { -+ $this->aSelectors = explode(',', $sSelectors); -+ } else { -+ $aSearches = array_keys( $aPlaceholders ); -+ $aReplaces = array_values( $aPlaceholders ); -+ $this->aSelectors = array_map( -+ function( $sSelector ) use ( $aSearches, $aReplaces ) { -+ return str_replace( $aSearches, $aReplaces, $sSelector ); -+ }, -+ explode(',', $sSelectors) -+ ); -+ } - } - foreach ($this->aSelectors as $iKey => $mSelector) { - if (!($mSelector instanceof Selector)) { -@@ -37,6 +49,52 @@ public function setSelectors($mSelector) { - } - } - -+ /** -+ * Add placeholders for parenthetical/bracketed expressions in selectors which may contain commas that break exploding. -+ * -+ * This prevents a single selector like `.widget:not(.foo, .bar)` from erroneously getting parsed in setSelectors as -+ * two selectors `.widget:not(.foo` and `.bar)`. -+ * -+ * @param string $sSelectors Selectors. -+ * @return array First array value is the selectors with placeholders, and second value is the array of placeholders mapped to the original expressions. -+ */ -+ private function addSelectorExpressionPlaceholders( $sSelectors ) { -+ $iOffset = 0; -+ $aPlaceholders = array(); -+ -+ while ( preg_match( '/\(|\[/', $sSelectors, $aMatches, PREG_OFFSET_CAPTURE, $iOffset ) ) { -+ $sMatchString = $aMatches[0][0]; -+ $iMatchOffset = $aMatches[0][1]; -+ $iStyleLength = strlen( $sSelectors ); -+ $iOpenParens = 1; -+ $iStartOffset = $iMatchOffset + strlen( $sMatchString ); -+ $iFinalOffset = $iStartOffset; -+ for ( ; $iFinalOffset < $iStyleLength; $iFinalOffset++ ) { -+ if ( '(' === $sSelectors[ $iFinalOffset ] || '[' === $sSelectors[ $iFinalOffset ] ) { -+ $iOpenParens++; -+ } elseif ( ')' === $sSelectors[ $iFinalOffset ] || ']' === $sSelectors[ $iFinalOffset ] ) { -+ $iOpenParens--; -+ } -+ -+ // Found the end of the expression, so replace it with a placeholder. -+ if ( 0 === $iOpenParens ) { -+ $sMatchedExpr = substr( $sSelectors, $iMatchOffset, $iFinalOffset - $iMatchOffset + 1 ); -+ $sPlaceholder = sprintf( '{placeholder:%d}', count( $aPlaceholders ) + 1 ); -+ $aPlaceholders[ $sPlaceholder ] = $sMatchedExpr; -+ -+ // Update the CSS to replace the matched calc() with the placeholder function. -+ $sSelectors = substr( $sSelectors, 0, $iMatchOffset ) . $sPlaceholder . substr( $sSelectors, $iFinalOffset + 1 ); -+ // Update offset based on difference of length of placeholder vs original matched calc(). -+ $iFinalOffset += strlen( $sPlaceholder ) - strlen( $sMatchedExpr ); -+ break; -+ } -+ } -+ // Start matching at the next byte after the match. -+ $iOffset = $iFinalOffset + 1; -+ } -+ return array( $sSelectors, $aPlaceholders ); -+ } -+ - // remove one of the selector of the block - public function removeSelector($mSelector) { - if($mSelector instanceof Selector) { -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index 43c22e2..a5073be 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -148,6 +148,12 @@ function testSpecificity() { - case "li.green": - $this->assertSame(11, $oSelector->getSpecificity()); - break; -+ case "div:not(.foo[title=\"a,b\"], .bar)": -+ $this->assertSame(31, $oSelector->getSpecificity()); -+ break; -+ case "div[title=\"a,b\"]": -+ $this->assertSame(11, $oSelector->getSpecificity()); -+ break; - default: - $this->fail("specificity: untested selector " . $oSelector->getSelector()); - } -diff --git a/tests/files/specificity.css b/tests/files/specificity.css -index 82a2939..df03ff0 100644 ---- a/tests/files/specificity.css -+++ b/tests/files/specificity.css -@@ -2,6 +2,8 @@ - #file, - .help:hover, - li.green, --ol li::before { -+ol li::before, -+div:not(.foo[title="a,b"], .bar), -+div[title="a,b"] { - font-family: Helvetica; - } - -From 10a2501c119abafced3e4014aa3c0a3453a86f67 Mon Sep 17 00:00:00 2001 -From: Weston Ruter -Date: Mon, 20 Apr 2020 13:53:44 -0700 -Subject: [PATCH 2/2] Update SELECTOR_VALIDATION_RX to account for - parenthetical groups - ---- - lib/Sabberworm/CSS/Property/Selector.php | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/Sabberworm/CSS/Property/Selector.php b/lib/Sabberworm/CSS/Property/Selector.php -index bd04b88..0f1c643 100644 ---- a/lib/Sabberworm/CSS/Property/Selector.php -+++ b/lib/Sabberworm/CSS/Property/Selector.php -@@ -43,6 +43,7 @@ class Selector { - [a-zA-Z0-9\x{00A0}-\x{FFFF}_^$|*="\'~\[\]()\-\s\.:#+>]* # any sequence of valid unescaped characters - (?:\\\\.)? # a single escaped character - (?:([\'"]).*?(? -Date: Wed, 22 Jan 2020 01:00:18 -0500 -Subject: [PATCH 1/5] Validate name-start code points for identifier - ---- - lib/Sabberworm/CSS/Parsing/ParserState.php | 40 +++++++++++++++++----- - lib/Sabberworm/CSS/Value/Color.php | 2 +- - tests/Sabberworm/CSS/ParserTest.php | 13 +++++-- - tests/files/-invalid-identifier.css | 6 ++++ - 4 files changed, 48 insertions(+), 13 deletions(-) - create mode 100644 tests/files/-invalid-identifier.css - -diff --git a/lib/Sabberworm/CSS/Parsing/ParserState.php b/lib/Sabberworm/CSS/Parsing/ParserState.php -index ad79820..1914f22 100644 ---- a/lib/Sabberworm/CSS/Parsing/ParserState.php -+++ b/lib/Sabberworm/CSS/Parsing/ParserState.php -@@ -48,8 +48,30 @@ public function getSettings() { - return $this->oParserSettings; - } - -- public function parseIdentifier($bIgnoreCase = true) { -- $sResult = $this->parseCharacter(true); -+ public function parseIdentifier($bIgnoreCase = true, $bNameStartCodePoint = true) { -+ $sResult = null; -+ $bCanParseCharacter = true; -+ -+ if ( $bNameStartCodePoint ) { -+ // Check if 3 code points would start an identifier. See . -+ $sNameStartCodePoint = '[a-zA-Z_]|[\x80-\xFF}]'; -+ $sEscapeCode = '\\[^\r\n\f]'; -+ -+ if ( -+ ! ( -+ preg_match("/-([-${sNameStartCodePoint}]|${sEscapeCode})/isSu", $this->peek(3)) || -+ preg_match("/${sNameStartCodePoint}/isSu", $this->peek()) || -+ preg_match("/${sEscapeCode}/isS", $this->peek(2)) -+ ) -+ ) { -+ $bCanParseCharacter = false; -+ } -+ } -+ -+ if ( $bCanParseCharacter ) { -+ $sResult = $this->parseCharacter(true); -+ } -+ - if ($sResult === null) { - throw new UnexpectedTokenException($sResult, $this->peek(5), 'identifier', $this->iLineNo); - } -@@ -97,13 +119,13 @@ public function parseCharacter($bIsForIdentifier) { - } - if ($bIsForIdentifier) { - $peek = ord($this->peek()); -- // Ranges: a-z A-Z 0-9 - _ -+ // Matches a name code point. See . - if (($peek >= 97 && $peek <= 122) || - ($peek >= 65 && $peek <= 90) || - ($peek >= 48 && $peek <= 57) || - ($peek === 45) || - ($peek === 95) || -- ($peek > 0xa1)) { -+ ($peek > 0x81)) { - return $this->consume(1); - } - } else { -@@ -261,22 +283,22 @@ public function strlen($sString) { - return mb_strlen($sString, $this->sCharset); - } else { - return strlen($sString); -- } -- } -+ } -+ } - - private function substr($iStart, $iLength) { - if ($iLength < 0) { - $iLength = $this->iLength - $iStart + $iLength; -- } -+ } - if ($iStart + $iLength > $this->iLength) { - $iLength = $this->iLength - $iStart; -- } -+ } - $sResult = ''; - while ($iLength > 0) { - $sResult .= $this->aText[$iStart]; - $iStart++; - $iLength--; -- } -+ } - return $sResult; - } - -diff --git a/lib/Sabberworm/CSS/Value/Color.php b/lib/Sabberworm/CSS/Value/Color.php -index c6ed9b1..f02777f 100644 ---- a/lib/Sabberworm/CSS/Value/Color.php -+++ b/lib/Sabberworm/CSS/Value/Color.php -@@ -14,7 +14,7 @@ public static function parse(ParserState $oParserState) { - $aColor = array(); - if ($oParserState->comes('#')) { - $oParserState->consume('#'); -- $sValue = $oParserState->parseIdentifier(false); -+ $sValue = $oParserState->parseIdentifier(false, false); - if ($oParserState->strlen($sValue) === 3) { - $sValue = $sValue[0] . $sValue[0] . $sValue[1] . $sValue[1] . $sValue[2] . $sValue[2]; - } else if ($oParserState->strlen($sValue) === 4) { -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index ea34f2e..16cae89 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -214,7 +214,7 @@ function testManipulation() { - $this->assertSame('#header {margin: 10px 2em 1cm 2%;color: red !important;frequency: 30Hz;} - body {color: green;}', $oDoc->render()); - } -- -+ - function testRuleGetters() { - $oDoc = $this->parsedStructureForFile('values'); - $aBlocks = $oDoc->getAllDeclarationBlocks(); -@@ -319,7 +319,7 @@ function testNamespaces() { - |test {gaga: 2;}'; - $this->assertSame($sExpected, $oDoc->render()); - } -- -+ - function testInnerColors() { - $oDoc = $this->parsedStructureForFile('inner-color'); - $sExpected = 'test {background: -webkit-gradient(linear,0 0,0 bottom,from(#006cad),to(hsl(202,100%,49%)));}'; -@@ -359,7 +359,7 @@ function testListValueRemoval() { - $this->assertSame('@media screen {html {some: -test(val2);}} - #unrelated {other: yes;}', $oDoc->render()); - } -- -+ - /** - * @expectedException Sabberworm\CSS\Parsing\OutputException - */ -@@ -766,4 +766,11 @@ function testLonelyImport() { - $sExpected = "@import url(\"example.css\") only screen and (max-width: 600px);"; - $this->assertSame($sExpected, $oDoc->render()); - } -+ -+ /** -+ * @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException -+ */ -+ function testInvalidIdentifier() { -+ $this->parsedStructureForFile('-invalid-identifier', Settings::create()->withLenientParsing(false)); -+ } - } -diff --git a/tests/files/-invalid-identifier.css b/tests/files/-invalid-identifier.css -new file mode 100644 -index 0000000..da00caf ---- /dev/null -+++ b/tests/files/-invalid-identifier.css -@@ -0,0 +1,6 @@ -+body { -+ transition: all .3s ease-in-out; -+ -webkit-transition: all .3s ease-in-out; -+ -moz-transition: all .3s ease-in-out; -+ -0-transition: all .3s ease-in-out; -+} - -From e031394fe3fc4448ed7e625e0c2b4ab334ad4ba2 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Sun, 26 Jan 2020 00:56:31 -0500 -Subject: [PATCH 2/5] Make validation of identifier more strict - ---- - lib/Sabberworm/CSS/Parsing/ParserState.php | 8 +++---- - tests/Sabberworm/CSS/ParserTest.php | 26 +++++++++++++++++++--- - tests/files/-invalid-identifier.css | 6 ----- - 3 files changed, 27 insertions(+), 13 deletions(-) - delete mode 100644 tests/files/-invalid-identifier.css - -diff --git a/lib/Sabberworm/CSS/Parsing/ParserState.php b/lib/Sabberworm/CSS/Parsing/ParserState.php -index 1914f22..2271d03 100644 ---- a/lib/Sabberworm/CSS/Parsing/ParserState.php -+++ b/lib/Sabberworm/CSS/Parsing/ParserState.php -@@ -54,14 +54,14 @@ public function parseIdentifier($bIgnoreCase = true, $bNameStartCodePoint = true - - if ( $bNameStartCodePoint ) { - // Check if 3 code points would start an identifier. See . -- $sNameStartCodePoint = '[a-zA-Z_]|[\x80-\xFF}]'; -+ $sNameStartCodePoint = '[a-zA-Z_]|[\x80-\xFF]'; - $sEscapeCode = '\\[^\r\n\f]'; - - if ( - ! ( -- preg_match("/-([-${sNameStartCodePoint}]|${sEscapeCode})/isSu", $this->peek(3)) || -- preg_match("/${sNameStartCodePoint}/isSu", $this->peek()) || -- preg_match("/${sEscapeCode}/isS", $this->peek(2)) -+ preg_match("/^-([-${sNameStartCodePoint}]|${sEscapeCode})/isSu", $this->peek(3)) || -+ preg_match("/^${sNameStartCodePoint}/isSu", $this->peek()) || -+ preg_match("/^${sEscapeCode}/isS", $this->peek(2)) - ) - ) { - $bCanParseCharacter = false; -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index 16cae89..921209e 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -767,10 +767,30 @@ function testLonelyImport() { - $this->assertSame($sExpected, $oDoc->render()); - } - -+ function getInvalidIdentifiers() { -+ return array( -+ array( -+ 'body { -0-transition: all .3s ease-in-out; }', -+ 'Identifier expected. Got “-0-tr” [line no: 1]' -+ ), -+ array( -+ 'body { 4-o-transition: all .3s ease-in-out; }', -+ 'Identifier expected. Got “4-o-t” [line no: 1]' -+ ) -+ ); -+ } -+ - /** -- * @expectedException \Sabberworm\CSS\Parsing\UnexpectedTokenException -+ * @dataProvider getInvalidIdentifiers - */ -- function testInvalidIdentifier() { -- $this->parsedStructureForFile('-invalid-identifier', Settings::create()->withLenientParsing(false)); -+ function testInvalidIdentifier($css, $errorMessage) { -+ try { -+ $settings = Settings::create()->withLenientParsing(false); -+ $parser = new Parser($css, $settings); -+ $parser->parse(); -+ $this->fail( 'UnexpectedTokenException not thrown' ); -+ } catch ( UnexpectedTokenException $e ) { -+ $this->assertEquals( $errorMessage, $e->getMessage() ); -+ } - } - } -diff --git a/tests/files/-invalid-identifier.css b/tests/files/-invalid-identifier.css -deleted file mode 100644 -index da00caf..0000000 ---- a/tests/files/-invalid-identifier.css -+++ /dev/null -@@ -1,6 +0,0 @@ --body { -- transition: all .3s ease-in-out; -- -webkit-transition: all .3s ease-in-out; -- -moz-transition: all .3s ease-in-out; -- -0-transition: all .3s ease-in-out; --} - -From 8fbd0fe82aa08ad2650def1b44f2f77154211e30 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Sun, 26 Jan 2020 01:08:21 -0500 -Subject: [PATCH 3/5] Refactor `testInvalidIdentifier` test - ---- - tests/Sabberworm/CSS/ParserTest.php | 27 ++++++++++----------------- - 1 file changed, 10 insertions(+), 17 deletions(-) - -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index 921209e..68284ce 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -769,28 +769,21 @@ function testLonelyImport() { - - function getInvalidIdentifiers() { - return array( -- array( -- 'body { -0-transition: all .3s ease-in-out; }', -- 'Identifier expected. Got “-0-tr” [line no: 1]' -- ), -- array( -- 'body { 4-o-transition: all .3s ease-in-out; }', -- 'Identifier expected. Got “4-o-t” [line no: 1]' -- ) -+ array('body { -0-transition: all .3s ease-in-out; }' ), -+ array('body { 4-o-transition: all .3s ease-in-out; }' ), - ); - } - - /** - * @dataProvider getInvalidIdentifiers -+ * -+ * @param string $css CSS text. - */ -- function testInvalidIdentifier($css, $errorMessage) { -- try { -- $settings = Settings::create()->withLenientParsing(false); -- $parser = new Parser($css, $settings); -- $parser->parse(); -- $this->fail( 'UnexpectedTokenException not thrown' ); -- } catch ( UnexpectedTokenException $e ) { -- $this->assertEquals( $errorMessage, $e->getMessage() ); -- } -+ function testInvalidIdentifier($css) { -+ $this->setExpectedException( 'Sabberworm\CSS\Parsing\UnexpectedTokenException' ); -+ -+ $oSettings = Settings::create()->withLenientParsing(false); -+ $oParser = new Parser($css, $oSettings); -+ $oParser->parse(); - } - } - -From 586c684a990458d70af55b47f584b619ad5c3a41 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Fri, 31 Jan 2020 15:55:54 -0500 -Subject: [PATCH 4/5] Recover from invalid identifier if in lenient mode - ---- - lib/Sabberworm/CSS/Parsing/ParserState.php | 2 +- - tests/Sabberworm/CSS/ParserTest.php | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Parsing/ParserState.php b/lib/Sabberworm/CSS/Parsing/ParserState.php -index 2271d03..7ab8e01 100644 ---- a/lib/Sabberworm/CSS/Parsing/ParserState.php -+++ b/lib/Sabberworm/CSS/Parsing/ParserState.php -@@ -72,7 +72,7 @@ public function parseIdentifier($bIgnoreCase = true, $bNameStartCodePoint = true - $sResult = $this->parseCharacter(true); - } - -- if ($sResult === null) { -+ if (!$this->oParserSettings->bLenientParsing && $sResult === null) { - throw new UnexpectedTokenException($sResult, $this->peek(5), 'identifier', $this->iLineNo); - } - $sCharacter = null; -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index 68284ce..ff8c5c9 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -769,8 +769,8 @@ function testLonelyImport() { - - function getInvalidIdentifiers() { - return array( -- array('body { -0-transition: all .3s ease-in-out; }' ), -- array('body { 4-o-transition: all .3s ease-in-out; }' ), -+ array('body { -0-transition: all .3s ease-in-out; }'), -+ array('body { 4-o-transition: all .3s ease-in-out; }'), - ); - } - - -From 113df5d55e94e21c6402021dfa959924941d4c29 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Fri, 14 Feb 2020 04:20:16 -0500 -Subject: [PATCH 5/5] Remove check of lenient parsing - -The thrown exception will be caught when in lenient mode ---- - lib/Sabberworm/CSS/Parsing/ParserState.php | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/Sabberworm/CSS/Parsing/ParserState.php b/lib/Sabberworm/CSS/Parsing/ParserState.php -index 7ab8e01..2271d03 100644 ---- a/lib/Sabberworm/CSS/Parsing/ParserState.php -+++ b/lib/Sabberworm/CSS/Parsing/ParserState.php -@@ -72,7 +72,7 @@ public function parseIdentifier($bIgnoreCase = true, $bNameStartCodePoint = true - $sResult = $this->parseCharacter(true); - } - -- if (!$this->oParserSettings->bLenientParsing && $sResult === null) { -+ if ($sResult === null) { - throw new UnexpectedTokenException($sResult, $this->peek(5), 'identifier', $this->iLineNo); - } - $sCharacter = null; diff --git a/patches/php-css-parser-pull-193.patch b/patches/php-css-parser-pull-193.patch deleted file mode 100644 index f7794118f6c..00000000000 --- a/patches/php-css-parser-pull-193.patch +++ /dev/null @@ -1,415 +0,0 @@ -From 2ab643b70569f703b560c9e1bfb4f25498f0dec4 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Wed, 6 May 2020 15:41:19 -0400 -Subject: [PATCH 1/7] Change turns to turn - ---- - lib/Sabberworm/CSS/Value/Size.php | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index 8490cc3..05f41ea 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -8,7 +8,7 @@ class Size extends PrimitiveValue { - - const ABSOLUTE_SIZE_UNITS = 'px/cm/mm/mozmm/in/pt/pc/vh/vw/vmin/vmax/rem'; //vh/vw/vm(ax)/vmin/rem are absolute insofar as they don’t scale to the immediate parent (only the viewport) - const RELATIVE_SIZE_UNITS = '%/em/ex/ch/fr'; -- const NON_SIZE_UNITS = 'deg/grad/rad/s/ms/turns/Hz/kHz'; -+ const NON_SIZE_UNITS = 'deg/grad/rad/s/ms/turn/Hz/kHz'; - - private static $SIZE_UNITS = null; - --- -2.25.1 - - -From 1e0d5367444c4b5b62b12ea16737a26657ef4eac Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Mon, 11 May 2020 03:16:27 -0400 -Subject: [PATCH 2/7] Output correct size unit in lenient mode; fail if unit - not valid - ---- - lib/Sabberworm/CSS/Value/Size.php | 15 +++++++++++++-- - tests/Sabberworm/CSS/ParserTest.php | 18 ++++++++++++++++++ - 2 files changed, 31 insertions(+), 2 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index 05f41ea..26ce9aa 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -3,6 +3,7 @@ - namespace Sabberworm\CSS\Value; - - use Sabberworm\CSS\Parsing\ParserState; -+use Sabberworm\CSS\Parsing\UnexpectedTokenException; - - class Size extends PrimitiveValue { - -@@ -38,11 +39,21 @@ class Size extends PrimitiveValue { - - $sUnit = null; - $aSizeUnits = self::getSizeUnits(); -- foreach($aSizeUnits as $iLength => &$aValues) { -+ $sUnit = strtolower($oParserState->parseIdentifier()); -+ $oParserState->backtrack(strlen($sUnit)); -+ -+ foreach($aSizeUnits as $iLength => $aValues) { -+ $iConsumeLength = $iLength; - $sKey = strtolower($oParserState->peek($iLength)); - if(array_key_exists($sKey, $aValues)) { -+ if ($sUnit !== $sKey) { -+ if (!$oParserState->getSettings()->bLenientParsing) { -+ throw new UnexpectedTokenException('Unit', $sUnit, 'identifier', $oParserState->currentLine()); -+ } -+ $iConsumeLength = strlen($sUnit); -+ } - if (($sUnit = $aValues[$sKey]) !== null) { -- $oParserState->consume($iLength); -+ $oParserState->consume($iConsumeLength); - break; - } - } -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index 4a69019..e457f99 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -787,4 +787,22 @@ body {background-url: url("http://somesite.com/images/someimage.gif");}'; - $sExpected = "@import url(\"example.css\") only screen and (max-width: 600px);"; - $this->assertSame($sExpected, $oDoc->render()); - } -+ -+ function testTurnUnitLenient() { -+ $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; -+ $sExpected = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turn);}"; -+ -+ $oParser = new Parser($sText); -+ $this->assertSame($sExpected, $oParser->parse()->render()); -+ } -+ -+ function testTurnUnitStrict() { -+ $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; -+ -+ $oParser = new Parser($sText, Settings::create()->beStrict()); -+ -+ // Line 2 contains the invalid unit and so should be reported. -+ $this->setExpectedException( 'Sabberworm\CSS\Parsing\UnexpectedTokenException', 'Identifier expected. Got “turns” [line no: 2]' ); -+ $oParser->parse(); -+ } - } --- -2.25.1 - - -From 848e803b64cd1ced0059b83a37605e14732e568a Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Mon, 11 May 2020 11:50:58 -0400 -Subject: [PATCH 3/7] Fix parsing unit - ---- - lib/Sabberworm/CSS/Value/Size.php | 30 +++++++++++++++++++++++------- - 1 file changed, 23 insertions(+), 7 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index 26ce9aa..ef12898 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -37,20 +37,36 @@ class Size extends PrimitiveValue { - } - } - -- $sUnit = null; -- $aSizeUnits = self::getSizeUnits(); -- $sUnit = strtolower($oParserState->parseIdentifier()); -- $oParserState->backtrack(strlen($sUnit)); -+ $sParsedUnit = ''; -+ $iOffset = 0; -+ while (true) { -+ $sChar = $oParserState->peek(1, $iOffset); -+ $iPeek = ord($sChar); -+ -+ // Ranges: a-z A-Z 0-9 % -+ if (($iPeek >= 97 && $iPeek <= 122) || -+ ($iPeek >= 65 && $iPeek <= 90) || -+ ($iPeek >= 48 && $iPeek <= 57) || -+ ($iPeek === 37)) { -+ $sParsedUnit .= $sChar; -+ $iOffset++; -+ } else { -+ break; -+ } -+ } -+ -+ $sUnit = null; -+ $aSizeUnits = self::getSizeUnits(); - - foreach($aSizeUnits as $iLength => $aValues) { - $iConsumeLength = $iLength; - $sKey = strtolower($oParserState->peek($iLength)); - if(array_key_exists($sKey, $aValues)) { -- if ($sUnit !== $sKey) { -+ if (strtolower($sParsedUnit) !== $sKey) { - if (!$oParserState->getSettings()->bLenientParsing) { -- throw new UnexpectedTokenException('Unit', $sUnit, 'identifier', $oParserState->currentLine()); -+ throw new UnexpectedTokenException('Unit', $sParsedUnit, 'identifier', $oParserState->currentLine()); - } -- $iConsumeLength = strlen($sUnit); -+ $iConsumeLength = strlen($sParsedUnit); - } - if (($sUnit = $aValues[$sKey]) !== null) { - $oParserState->consume($iConsumeLength); --- -2.25.1 - - -From ca2d6e7dc88cca27f3e0192677baddd81f3c1c80 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Mon, 11 May 2020 15:21:45 -0400 -Subject: [PATCH 4/7] Revert truncation of unit - ---- - lib/Sabberworm/CSS/Value/Size.php | 50 +++++++++++++---------------- - tests/Sabberworm/CSS/ParserTest.php | 26 +++++++-------- - 2 files changed, 36 insertions(+), 40 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index ef12898..e26a354 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -37,39 +37,35 @@ class Size extends PrimitiveValue { - } - } - -- $sParsedUnit = ''; -- $iOffset = 0; -+ $sParsedUnit = ''; -+ $iOffset = 0; - while (true) { -- $sChar = $oParserState->peek(1, $iOffset); -- $iPeek = ord($sChar); -- -- // Ranges: a-z A-Z 0-9 % -- if (($iPeek >= 97 && $iPeek <= 122) || -- ($iPeek >= 65 && $iPeek <= 90) || -- ($iPeek >= 48 && $iPeek <= 57) || -- ($iPeek === 37)) { -- $sParsedUnit .= $sChar; -- $iOffset++; -- } else { -- break; -- } -- } -- -- $sUnit = null; -- $aSizeUnits = self::getSizeUnits(); -+ $sChar = $oParserState->peek(1, $iOffset); -+ $iPeek = ord($sChar); -+ -+ // Ranges: a-z A-Z 0-9 % -+ if (($iPeek >= 97 && $iPeek <= 122) || -+ ($iPeek >= 65 && $iPeek <= 90) || -+ ($iPeek >= 48 && $iPeek <= 57) || -+ ($iPeek === 37)) { -+ $sParsedUnit .= $sChar; -+ $iOffset++; -+ } else { -+ break; -+ } -+ } -+ -+ $sUnit = null; -+ $aSizeUnits = self::getSizeUnits(); - - foreach($aSizeUnits as $iLength => $aValues) { -- $iConsumeLength = $iLength; - $sKey = strtolower($oParserState->peek($iLength)); - if(array_key_exists($sKey, $aValues)) { -- if (strtolower($sParsedUnit) !== $sKey) { -- if (!$oParserState->getSettings()->bLenientParsing) { -- throw new UnexpectedTokenException('Unit', $sParsedUnit, 'identifier', $oParserState->currentLine()); -- } -- $iConsumeLength = strlen($sParsedUnit); -- } -+ if (strtolower($sParsedUnit) !== $sKey) { -+ throw new UnexpectedTokenException('Unit', $sParsedUnit, 'identifier', $oParserState->currentLine()); -+ } - if (($sUnit = $aValues[$sKey]) !== null) { -- $oParserState->consume($iConsumeLength); -+ $oParserState->consume($iLength); - break; - } - } -diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php -index e457f99..6ef74bb 100644 ---- a/tests/Sabberworm/CSS/ParserTest.php -+++ b/tests/Sabberworm/CSS/ParserTest.php -@@ -788,21 +788,21 @@ body {background-url: url("http://somesite.com/images/someimage.gif");}'; - $this->assertSame($sExpected, $oDoc->render()); - } - -- function testTurnUnitLenient() { -- $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; -- $sExpected = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turn);}"; -+ function testTurnUnitLenient() { -+ $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; -+ $sExpected = ".foo {transform: rotate(1turn);}\n.bar {}"; - -- $oParser = new Parser($sText); -- $this->assertSame($sExpected, $oParser->parse()->render()); -- } -+ $oParser = new Parser($sText); -+ $this->assertSame($sExpected, $oParser->parse()->render()); -+ } - -- function testTurnUnitStrict() { -- $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; -+ function testTurnUnitStrict() { -+ $sText = ".foo {transform: rotate(1turn);}\n.bar {transform: rotate(1turns);}"; - -- $oParser = new Parser($sText, Settings::create()->beStrict()); -+ $oParser = new Parser($sText, Settings::create()->beStrict()); - -- // Line 2 contains the invalid unit and so should be reported. -- $this->setExpectedException( 'Sabberworm\CSS\Parsing\UnexpectedTokenException', 'Identifier expected. Got “turns” [line no: 2]' ); -- $oParser->parse(); -- } -+ // Line 2 contains the invalid unit and so should be reported. -+ $this->setExpectedException( 'Sabberworm\CSS\Parsing\UnexpectedTokenException', 'Identifier expected. Got “turns” [line no: 2]' ); -+ $oParser->parse(); -+ } - } --- -2.25.1 - - -From d35c18f6924b2d26fac666a400ca5018beb61324 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Mon, 11 May 2020 17:10:41 -0400 -Subject: [PATCH 5/7] Simplify logic for parsing size unit - ---- - lib/Sabberworm/CSS/Value/Size.php | 24 ++++++------------------ - 1 file changed, 6 insertions(+), 18 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index e26a354..9cfe890 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -37,27 +37,15 @@ class Size extends PrimitiveValue { - } - } - -- $sParsedUnit = ''; -- $iOffset = 0; -- while (true) { -- $sChar = $oParserState->peek(1, $iOffset); -- $iPeek = ord($sChar); -- -- // Ranges: a-z A-Z 0-9 % -- if (($iPeek >= 97 && $iPeek <= 122) || -- ($iPeek >= 65 && $iPeek <= 90) || -- ($iPeek >= 48 && $iPeek <= 57) || -- ($iPeek === 37)) { -- $sParsedUnit .= $sChar; -- $iOffset++; -- } else { -- break; -- } -- } -- - $sUnit = null; -+ $sParsedUnit = null; - $aSizeUnits = self::getSizeUnits(); - -+ $iMaxSizeUnitLength = max(array_keys($aSizeUnits)); -+ if ( preg_match( '/^[a-zA-Z0-9%]+/', $oParserState->peek($iMaxSizeUnitLength), $matches ) ) { -+ $sParsedUnit = $matches[0]; -+ } -+ - foreach($aSizeUnits as $iLength => $aValues) { - $sKey = strtolower($oParserState->peek($iLength)); - if(array_key_exists($sKey, $aValues)) { --- -2.25.1 - - -From b19d79be31b8b71300182f6c10a326386ec65d05 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon -Date: Mon, 11 May 2020 17:53:50 -0400 -Subject: [PATCH 6/7] Refactor size unit parsing logic - ---- - lib/Sabberworm/CSS/Value/Size.php | 23 +++++++++-------------- - 1 file changed, 9 insertions(+), 14 deletions(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index 9cfe890..26e3eb1 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -38,26 +38,21 @@ class Size extends PrimitiveValue { - } - - $sUnit = null; -- $sParsedUnit = null; - $aSizeUnits = self::getSizeUnits(); -- - $iMaxSizeUnitLength = max(array_keys($aSizeUnits)); -+ - if ( preg_match( '/^[a-zA-Z0-9%]+/', $oParserState->peek($iMaxSizeUnitLength), $matches ) ) { -- $sParsedUnit = $matches[0]; -- } -+ $sUnit = strtolower($matches[0]); -+ $iUnitLength = strlen($sUnit); - -- foreach($aSizeUnits as $iLength => $aValues) { -- $sKey = strtolower($oParserState->peek($iLength)); -- if(array_key_exists($sKey, $aValues)) { -- if (strtolower($sParsedUnit) !== $sKey) { -- throw new UnexpectedTokenException('Unit', $sParsedUnit, 'identifier', $oParserState->currentLine()); -- } -- if (($sUnit = $aValues[$sKey]) !== null) { -- $oParserState->consume($iLength); -- break; -- } -+ if (isset($aSizeUnits[$iUnitLength][$sUnit])) { -+ $sUnit = $aSizeUnits[$iUnitLength][$sUnit]; -+ $oParserState->consume($iUnitLength); -+ } else { -+ throw new UnexpectedTokenException('Unit', $sUnit, 'identifier', $oParserState->currentLine()); - } - } -+ - return new Size(floatval($sSize), $sUnit, $bIsColorComponent, $oParserState->currentLine()); - } - --- -2.25.1 - - -From 9862b6087d0f5c8c8406d8e3033fde5352ad0c90 Mon Sep 17 00:00:00 2001 -From: Pierre Gordon <16200219+pierlon@users.noreply.github.com> -Date: Mon, 11 May 2020 19:22:45 -0400 -Subject: [PATCH 7/7] Match percent symbol or alphanumeric text - -Co-authored-by: Weston Ruter ---- - lib/Sabberworm/CSS/Value/Size.php | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php -index 26e3eb1..cd1a213 100644 ---- a/lib/Sabberworm/CSS/Value/Size.php -+++ b/lib/Sabberworm/CSS/Value/Size.php -@@ -41,7 +41,7 @@ class Size extends PrimitiveValue { - $aSizeUnits = self::getSizeUnits(); - $iMaxSizeUnitLength = max(array_keys($aSizeUnits)); - -- if ( preg_match( '/^[a-zA-Z0-9%]+/', $oParserState->peek($iMaxSizeUnitLength), $matches ) ) { -+ if ( preg_match( '/^(%|[a-zA-Z0-9]+)/', $oParserState->peek($iMaxSizeUnitLength), $matches ) ) { - $sUnit = strtolower($matches[0]); - $iUnitLength = strlen($sUnit); - --- -2.25.1 -