diff --git a/amp.php b/amp.php index c2e988c0e58..42b16471322 100644 --- a/amp.php +++ b/amp.php @@ -64,6 +64,11 @@ 'DOMXPath', ), ), + 'filter' => array( + 'functions' => array( + 'filter_var', + ), + ), // Required by PHP-CSS-Parser. 'iconv' => array( 'functions' => array( 'iconv' ), diff --git a/composer.json b/composer.json index 45d6e89d3da..e94ed3094ff 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,12 @@ "ext-curl": "*", "ext-date": "*", "ext-dom": "*", + "ext-filter": "*", "ext-iconv": "*", "ext-json": "*", "ext-libxml": "*", "ext-spl": "*", - "ampproject/amp-toolbox": "^0.3", + "ampproject/amp-toolbox": "dev-main", "cweagans/composer-patches": "1.7.0", "fasterimage/fasterimage": "1.5.0", "sabberworm/php-css-parser": "dev-master#bfdd976" diff --git a/composer.lock b/composer.lock index c2731c6a14a..d6e9c37e8e8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,24 +4,25 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8ce341eb95c49935f972bd22a8b30c43", + "content-hash": "d94392c0c59201d458d0f3139fa0b7fe", "packages": [ { "name": "ampproject/amp-toolbox", - "version": "0.3.0", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/ampproject/amp-toolbox-php.git", - "reference": "227563fe216069b2f33a652f8524d344662ba2e7" + "reference": "90452d0ef26f60947c7baf9bad221b3b97ff4ca3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/227563fe216069b2f33a652f8524d344662ba2e7", - "reference": "227563fe216069b2f33a652f8524d344662ba2e7", + "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/90452d0ef26f60947c7baf9bad221b3b97ff4ca3", + "reference": "90452d0ef26f60947c7baf9bad221b3b97ff4ca3", "shasum": "" }, "require": { "ext-dom": "*", + "ext-filter": "*", "ext-iconv": "*", "ext-json": "*", "ext-libxml": "*", @@ -43,6 +44,9 @@ "ext-json": "Provides native implementation of json_encode()/json_decode().", "ext-mbstring": "Used by Dom\\Document to convert encoding to UTF-8 if needed." }, + "bin": [ + "bin/amp" + ], "type": "library", "extra": { "downloads": { @@ -63,7 +67,7 @@ "Apache-2.0" ], "description": "A collection of AMP tools making it easier to publish and host AMP pages with PHP.", - "time": "2021-03-29T21:05:18+00:00" + "time": "2021-04-10T15:34:10+00:00" }, { "name": "cweagans/composer-patches", @@ -1120,16 +1124,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.7.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3" + "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3", - "reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1", + "reference": "35ea11d335fd638b5882ff1725228b3d35496ab1", "shasum": "" }, "require": { @@ -1187,7 +1191,11 @@ "uri", "url" ], - "time": "2020-09-30T07:37:11+00:00" + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/1.8.1" + }, + "time": "2021-03-21T16:25:00+00:00" }, { "name": "mikey179/vfsstream", @@ -1639,21 +1647,21 @@ }, { "name": "php-parallel-lint/php-parallel-lint", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", - "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca" + "reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/474f18bc6cc6aca61ca40bfab55139de614e51ca", - "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/772a954e5f119f6f5871d015b23eabed8cbdadfb", + "reference": "772a954e5f119f6f5871d015b23eabed8cbdadfb", "shasum": "" }, "require": { "ext-json": "*", - "php": ">=5.4.0" + "php": ">=5.3.0" }, "replace": { "grogy/php-parallel-lint": "*", @@ -1662,7 +1670,7 @@ "require-dev": { "nette/tester": "^1.3 || ^2.0", "php-parallel-lint/php-console-highlighter": "~0.3", - "squizlabs/php_codesniffer": "~3.0" + "squizlabs/php_codesniffer": "^3.5" }, "suggest": { "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" @@ -1688,7 +1696,7 @@ ], "description": "This tool check syntax of PHP files about 20x faster than serial check.", "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", - "time": "2020-04-04T12:18:32+00:00" + "time": "2021-04-07T14:42:48+00:00" }, { "name": "php-stubs/wordpress-stubs", @@ -2779,12 +2787,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "fe6ef201f838f07770873731a99f359ebb64fa50" + "reference": "aa48fe959b0236eede9c51a38f47df2bb81ef137" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/fe6ef201f838f07770873731a99f359ebb64fa50", - "reference": "fe6ef201f838f07770873731a99f359ebb64fa50", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/aa48fe959b0236eede9c51a38f47df2bb81ef137", + "reference": "aa48fe959b0236eede9c51a38f47df2bb81ef137", "shasum": "" }, "conflict": { @@ -2828,7 +2836,7 @@ "doctrine/doctrine-module": "<=0.7.1", "doctrine/mongodb-odm": ">=1,<1.0.2", "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", - "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1", + "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1|>=2.8.3,<2.8.4", "dolibarr/dolibarr": "<11.0.4", "dompdf/dompdf": ">=0.6,<0.6.2", "drupal/core": ">=7,<7.74|>=8,<8.8.11|>=8.9,<8.9.9|>=9,<9.0.8", @@ -2843,18 +2851,19 @@ "ezsystems/ezplatform": ">=1.7,<1.7.9.1|>=1.13,<1.13.5.1|>=2.5,<2.5.4", "ezsystems/ezplatform-admin-ui": ">=1.3,<1.3.5|>=1.4,<1.4.6", "ezsystems/ezplatform-admin-ui-assets": ">=4,<4.2.1|>=5,<5.0.1|>=5.1,<5.1.1", - "ezsystems/ezplatform-kernel": ">=1,<1.0.2.1", + "ezsystems/ezplatform-kernel": "<=1.2.5|>=1.3,<=1.3.1", "ezsystems/ezplatform-rest": ">=1.2,<=1.2.2|>=1.3,<=1.3.1", "ezsystems/ezplatform-user": ">=1,<1.0.1", - "ezsystems/ezpublish-kernel": ">=5.3,<5.3.12.1|>=5.4,<5.4.14.2|>=6,<6.7.9.1|>=6.8,<=6.13.8|>=7,<7.2.4.1|>=7.3,<7.3.2.1|>=7.5,<=7.5.15", + "ezsystems/ezpublish-kernel": "<=6.13.8.1|>=7,<=7.5.15.1", "ezsystems/ezpublish-legacy": ">=5.3,<5.3.12.6|>=5.4,<5.4.14.2|>=2011,<2017.12.7.3|>=2018.6,<2018.6.1.4|>=2018.9,<2018.9.1.3|>=2019.3,<2019.3.5.1", "ezsystems/platform-ui-assets-bundle": ">=4.2,<4.2.3", "ezsystems/repository-forms": ">=2.3,<2.3.2.1", "ezyang/htmlpurifier": "<4.1.1", - "facade/ignition": "<=2.5.1,>=2.0|<=1.16.13", + "facade/ignition": "<1.16.14|>=2,<2.4.2|>=2.5,<2.5.2", "firebase/php-jwt": "<2", "flarum/sticky": ">=0.1-beta.14,<=0.1-beta.15", "flarum/tags": "<=0.1-beta.13", + "fluidtypo3/vhs": "<5.1.1", "fooman/tcpdf": "<6.2.22", "fossar/tcpdf-parser": "<6.2.22", "friendsofsymfony/oauth2-php": "<1.3", @@ -2894,10 +2903,11 @@ "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", - "mautic/core": "<2.16.5|>=3,<3.2.4|= 2.13.1", + "mautic/core": "<3.3.2|= 2.13.1", "mediawiki/core": ">=1.27,<1.27.6|>=1.29,<1.29.3|>=1.30,<1.30.2|>=1.31,<1.31.9|>=1.32,<1.32.6|>=1.32.99,<1.33.3|>=1.33.99,<1.34.3|>=1.34.99,<1.35", "mittwald/typo3_forum": "<1.2.1", "monolog/monolog": ">=1.8,<1.12", + "moodle/moodle": "<3.5.17|>=3.7,<3.7.9|>=3.8,<3.8.8|>=3.9,<3.9.5|>=3.10,<3.10.2", "namshi/jose": "<2.2", "nette/application": ">=2,<2.0.19|>=2.1,<2.1.13|>=2.2,<2.2.10|>=2.3,<2.3.14|>=2.4,<2.4.16|>=3,<3.0.6", "nette/nette": ">=2,<2.0.19|>=2.1,<2.1.13", @@ -2927,15 +2937,18 @@ "phpmyadmin/phpmyadmin": "<4.9.6|>=5,<5.0.3", "phpoffice/phpexcel": "<1.8.2", "phpoffice/phpspreadsheet": "<1.16", + "phpseclib/phpseclib": "<2.0.31|>=3,<3.0.7", "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", "phpwhois/phpwhois": "<=4.2.5", "phpxmlrpc/extras": "<0.6.1", "pimcore/pimcore": "<6.8.8", "pocketmine/pocketmine-mp": "<3.15.4", + "pressbooks/pressbooks": "<5.18", "prestashop/autoupgrade": ">=4,<4.10.1", "prestashop/contactform": ">1.0.1,<4.3", "prestashop/gamification": "<2.3.2", "prestashop/productcomments": ">=4,<4.2.1", + "prestashop/ps_emailsubscription": "<2.6.1", "prestashop/ps_facetedsearch": "<3.4.1", "privatebin/privatebin": "<1.2.2|>=1.3,<1.3.2", "propel/propel": ">=2-alpha.1,<=2-alpha.7", @@ -3024,7 +3037,9 @@ "truckersmp/phpwhois": "<=4.3.1", "twig/twig": "<1.38|>=2,<2.7", "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.38|>=9,<9.5.25|>=10,<10.4.14|>=11,<11.1.1", - "typo3/cms-core": ">=8,<8.7.38|>=9,<9.5.25|>=10,<10.4.14|>=11,<11.1.1", + "typo3/cms-backend": ">=7,<=7.6.50|>=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", + "typo3/cms-core": ">=6.2,<=6.2.56|>=7,<=7.6.50|>=8,<=8.7.39|>=9,<9.5.25|>=10,<10.4.14|>=11,<11.1.1", + "typo3/cms-form": ">=8,<=8.7.39|>=9,<=9.5.24|>=10,<=10.4.13|>=11,<=11.1", "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", "typo3/phar-stream-wrapper": ">=1,<2.1.1|>=3,<3.1.1", @@ -3034,6 +3049,7 @@ "verot/class.upload.php": "<=1.0.3|>=2,<=2.0.4", "vrana/adminer": "<4.7.9", "wallabag/tcpdf": "<6.2.22", + "wikimedia/parsoid": "<0.12.2", "willdurand/js-translation-bundle": "<2.1.1", "yii2mod/yii2-cms": "<1.9.2", "yiisoft/yii": ">=1.1.14,<1.1.15", @@ -3099,7 +3115,7 @@ "type": "tidelift" } ], - "time": "2021-03-16T14:08:12+00:00" + "time": "2021-04-09T08:01:23+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -3670,16 +3686,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.8", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", - "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", "shasum": "" }, "require": { @@ -3717,7 +3733,7 @@ "phpcs", "standards" ], - "time": "2020-10-23T02:01:07+00:00" + "time": "2021-04-09T00:54:41+00:00" }, { "name": "symfony/config", @@ -5581,6 +5597,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "ampproject/amp-toolbox": 20, "sabberworm/php-css-parser": 20, "roave/security-advisories": 20 }, @@ -5591,6 +5608,7 @@ "ext-curl": "*", "ext-date": "*", "ext-dom": "*", + "ext-filter": "*", "ext-iconv": "*", "ext-json": "*", "ext-libxml": "*", diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php index e0b6b65d849..17ec016ceff 100644 --- a/includes/class-amp-theme-support.php +++ b/includes/class-amp-theme-support.php @@ -1388,7 +1388,7 @@ public static function filter_admin_bar_script_loader_tag( $tag, $handle ) { */ public static function ensure_required_markup( Document $dom, $script_handles = [] ) { // Gather all links. - $links = [ + $links = [ Attribute::REL_PRECONNECT => [ // Include preconnect link for AMP CDN for browsers that don't support preload. AMP_DOM_Utils::create_node( @@ -1401,7 +1401,9 @@ public static function ensure_required_markup( Document $dom, $script_handles = ), ], ]; + $link_elements = $dom->head->getElementsByTagName( Tag::LINK ); + /** * Link element. * @@ -1500,32 +1502,16 @@ public static function ensure_required_markup( Document $dom, $script_handles = } } - /* phpcs:ignore Squiz.PHP.CommentedOutCode.Found - * - * "2. Next, preload the AMP runtime v0.js ', $sanitized_html ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript + $this->assertStringContains( 'https://cdn.ampproject.org/v0/amp-mathml-0.1.js', $sanitized_html ); // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript } /** @@ -1642,23 +1642,22 @@ static function ( $url ) { '', '', - '', '', - '', '', - '', '', '', - '', + '', - '', - '', + '', + '', + '', - '#\s*#s', - '##s', - '', - '', + '', + '', + '', + '', '', '', @@ -1666,11 +1665,12 @@ static function ( $url ) { '##s', + '', + '<link rel="canonical" href="', '<script type="application/ld+json">{"@context"', '#<style amp-boilerplate(="")?>#', '#<noscript><style amp-boilerplate(="")?>#', - '<link rel="canonical" href="', '</head>', ];