From 24d0990aafe85fff0d36b341854087c15ce9d45f Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 25 Oct 2023 12:28:49 +0530 Subject: [PATCH 1/3] Bump ampproject/amp-toolbox to dev-main --- composer.json | 2 +- composer.lock | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 7645453f362..abc84b668e8 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "ext-json": "*", "ext-libxml": "*", "ext-spl": "*", - "ampproject/amp-toolbox": "0.11.3", + "ampproject/amp-toolbox": "dev-main", "cweagans/composer-patches": "^1.0", "fasterimage/fasterimage": "1.5.0", "sabberworm/php-css-parser": "dev-master#cc791ad" diff --git a/composer.lock b/composer.lock index 95a5526af75..080d5f85e14 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d9195e33ee6f648c1742b605ba7414a7", + "content-hash": "06d098e8f871b8cc6e0e676e8ee4c226", "packages": [ { "name": "ampproject/amp-toolbox", - "version": "0.11.3", + "version": "dev-main", "source": { "type": "git", "url": "https://github.com/ampproject/amp-toolbox-php.git", - "reference": "56c812508f5ebe538036d75cf0c21de094b316d3" + "reference": "c79a0fe558a3c042aee4789bbf33376cca7a733d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/56c812508f5ebe538036d75cf0c21de094b316d3", - "reference": "56c812508f5ebe538036d75cf0c21de094b316d3", + "url": "https://api.github.com/repos/ampproject/amp-toolbox-php/zipball/c79a0fe558a3c042aee4789bbf33376cca7a733d", + "reference": "c79a0fe558a3c042aee4789bbf33376cca7a733d", "shasum": "" }, "require": { @@ -48,6 +48,7 @@ "mck89/peast": "Needed to minify the AMP script.", "nette/php-generator": "Needed to generate the validator spec PHP classes and interfaces." }, + "default-branch": true, "bin": [ "bin/amp" ], @@ -76,9 +77,9 @@ "description": "A collection of AMP tools making it easier to publish and host AMP pages with PHP.", "support": { "issues": "https://github.com/ampproject/amp-toolbox-php/issues", - "source": "https://github.com/ampproject/amp-toolbox-php/tree/0.11.3" + "source": "https://github.com/ampproject/amp-toolbox-php/tree/main" }, - "time": "2023-02-07T23:27:03+00:00" + "time": "2023-10-24T22:47:58+00:00" }, { "name": "cweagans/composer-patches", @@ -8136,6 +8137,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "ampproject/amp-toolbox": 20, "sabberworm/php-css-parser": 20, "roave/security-advisories": 20 }, @@ -8156,5 +8158,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 67ebeea531664b3ca559a5b2ba5b649d563b140a Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 25 Oct 2023 12:30:13 +0530 Subject: [PATCH 2/3] Update img sanitizer to avoid adding `fetchpriority` attribute to amp-img --- includes/sanitizers/class-amp-img-sanitizer.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/sanitizers/class-amp-img-sanitizer.php b/includes/sanitizers/class-amp-img-sanitizer.php index f4bcf30d482..914153e2e48 100644 --- a/includes/sanitizers/class-amp-img-sanitizer.php +++ b/includes/sanitizers/class-amp-img-sanitizer.php @@ -298,6 +298,10 @@ private function filter_attributes( $attributes ) { } break; + // Avoid adding `fetchpriority` to amp-img element. + case Attribute::FETCHPRIORITY: + break; + default: $out[ $name ] = $value; break; From 1df48d7a6e0f3cf7dc43d62d0fdb1c86f837ca52 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 25 Oct 2023 13:29:23 +0530 Subject: [PATCH 3/3] Add test cases for fetchpriority attr in `AMP_Img_Sanitizer` --- tests/php/test-amp-img-sanitizer.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/php/test-amp-img-sanitizer.php b/tests/php/test-amp-img-sanitizer.php index 9128703ce12..7510533e3bf 100644 --- a/tests/php/test-amp-img-sanitizer.php +++ b/tests/php/test-amp-img-sanitizer.php @@ -595,6 +595,27 @@ public function get_data() { 'native_img_used' => false, ], ], + + 'fetchpriority_attr_not_added_to_amp-img' => [ + '', + '', + [ + 'add_noscript_fallback' => false, + ], + ], + + 'fetchpriority_attr_is_preserved_in_noscript_fallback_img' => [ + '', + '', + ], + + 'fetchpriority_attr_is_preserved_in_native_img' => [ + '', + '', + [ + 'native_img_used' => true, + ], + ], ]; }