From 7b0a35b623db32770b5ba5387540c641119fe50b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 2 Apr 2026 22:29:22 +0000
Subject: [PATCH 1/7] Initial plan
From e50c815449ee824d8ee94852ef6758abec1f270c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 2 Apr 2026 22:42:50 +0000
Subject: [PATCH 2/7] Fix operator precedence in add_schema() and triple-slash
URL normalization in build_url()
Agent-Logs-Url: https://github.com/Codeinwp/optimole-wp/sessions/b12c03d6-d980-4909-8199-8aafbe58a311
Co-authored-by: kushh23 <110405452+kushh23@users.noreply.github.com>
---
inc/traits/normalizer.php | 2 +-
inc/url_replacer.php | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/inc/traits/normalizer.php b/inc/traits/normalizer.php
index 73c63525..dce1af86 100644
--- a/inc/traits/normalizer.php
+++ b/inc/traits/normalizer.php
@@ -372,7 +372,7 @@ public function add_schema( $url ) {
$should_add_schema = substr( $schema_url, 0, strlen( '//' ) ) === '//';
}
if ( $should_add_schema ) {
- $schema_url = is_ssl() ? 'https:' : 'http:' . $schema_url;
+ $schema_url = ( is_ssl() ? 'https:' : 'http:' ) . $schema_url;
}
return $schema_url;
}
diff --git a/inc/url_replacer.php b/inc/url_replacer.php
index 1540f90c..4370fa2e 100644
--- a/inc/url_replacer.php
+++ b/inc/url_replacer.php
@@ -154,7 +154,8 @@ public function build_url(
$url = str_replace( array_keys( $this->site_mappings ), array_values( $this->site_mappings ), $url );
}
if ( substr( $url, 0, 2 ) === '//' ) {
- $url = sprintf( '%s:%s', is_ssl() ? 'https' : 'http', $url );
+ $url = ltrim( $url, '/' );
+ $url = sprintf( '%s://%s', is_ssl() ? 'https' : 'http', $url );
}
$normalized_ext = strtolower( $ext );
if ( isset( Optml_Config::$image_extensions[ $normalized_ext ] ) ) {
From 299e3ae98735f068cfc50f585edbb1dc6e7746fd Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 3 Apr 2026 10:55:28 +0000
Subject: [PATCH 3/7] Add regression tests for add_schema() SSL operator
precedence and triple-slash URL normalization
Agent-Logs-Url: https://github.com/Codeinwp/optimole-wp/sessions/0b947f08-2140-4d1b-9330-9381b891257a
Co-authored-by: kushh23 <110405452+kushh23@users.noreply.github.com>
---
tests/test-generic.php | 28 ++++++++++++++++++++++++++++
tests/test-replacer.php | 15 +++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/tests/test-generic.php b/tests/test-generic.php
index fef9a2a9..6243f670 100644
--- a/tests/test-generic.php
+++ b/tests/test-generic.php
@@ -169,6 +169,34 @@ function test_get_unoptimized_url_edge_cases() {
$this->assertEquals( $uploaded_url, $result );
}
+ /**
+ * Test add_schema() prepends http: for protocol-relative URLs on non-SSL.
+ */
+ function test_add_schema_non_ssl() {
+ $this->assertEquals( 'http://example.org/image.jpg', $this->add_schema( '//example.org/image.jpg' ) );
+ }
+
+ /**
+ * Test add_schema() prepends https: for protocol-relative URLs on SSL.
+ * Regression: operator-precedence bug caused https: to be returned bare instead of https://example.org/...
+ */
+ function test_add_schema_ssl() {
+ $_SERVER['HTTPS'] = 'on';
+ $result = $this->add_schema( '//example.org/image.jpg' );
+ unset( $_SERVER['HTTPS'] );
+
+ $this->assertEquals( 'https://example.org/image.jpg', $result );
+ $this->assertStringNotEquals( 'https:', $result );
+ }
+
+ /**
+ * Test add_schema() leaves already-schemed URLs unchanged.
+ */
+ function test_add_schema_already_schemed() {
+ $this->assertEquals( 'http://example.org/image.jpg', $this->add_schema( 'http://example.org/image.jpg' ) );
+ $this->assertEquals( 'https://example.org/image.jpg', $this->add_schema( 'https://example.org/image.jpg' ) );
+ }
+
/**
* Test get_unoptimized_url with custom domain configuration.
*/
diff --git a/tests/test-replacer.php b/tests/test-replacer.php
index 6f482db3..4d7aa822 100644
--- a/tests/test-replacer.php
+++ b/tests/test-replacer.php
@@ -450,6 +450,21 @@ public function test_replacement_without_scheme() {
$this->assertStringContainsString( 'http://www.example.org', $replaced_content );
}
+ /**
+ * Regression test: triple-slash URLs (///host/path) must be normalized to
+ * http(s)://host/path before CDN embedding — never produce https:///host/path.
+ */
+ public function test_replacement_triple_slash_url() {
+ $content = '
+

+
';
+ $replaced_content = Optml_Manager::instance()->replace_content( $content );
+
+ $this->assertStringContainsString( 'i.optimole.com', $replaced_content );
+ $this->assertStringNotContainsString( ':///', $replaced_content );
+ $this->assertStringContainsString( 'http://www.example.org', $replaced_content );
+ }
+
public function test_non_allowed_extensions() {
$replaced_content = Optml_Manager::instance()->replace_content( ( self::CSS_STYLE . self::IMG_TAGS . self::WRONG_EXTENSION ) );
$this->assertStringContainsString( 'i.optimole.com', $replaced_content );
From 9e725b8feea25eea869fb09f397d91af5525b7b2 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 3 Apr 2026 10:55:58 +0000
Subject: [PATCH 4/7] Remove redundant assertion in test_add_schema_ssl
Agent-Logs-Url: https://github.com/Codeinwp/optimole-wp/sessions/0b947f08-2140-4d1b-9330-9381b891257a
Co-authored-by: kushh23 <110405452+kushh23@users.noreply.github.com>
---
tests/test-generic.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test-generic.php b/tests/test-generic.php
index 6243f670..3d9d2954 100644
--- a/tests/test-generic.php
+++ b/tests/test-generic.php
@@ -186,7 +186,6 @@ function test_add_schema_ssl() {
unset( $_SERVER['HTTPS'] );
$this->assertEquals( 'https://example.org/image.jpg', $result );
- $this->assertStringNotEquals( 'https:', $result );
}
/**
From 0cf464e1cada644e32ab1799ae73be08a5bf18f3 Mon Sep 17 00:00:00 2001
From: Kush Namdev <110405452+kushh23@users.noreply.github.com>
Date: Fri, 3 Apr 2026 16:41:53 +0530
Subject: [PATCH 5/7] Update tests/test-generic.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
tests/test-generic.php | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/tests/test-generic.php b/tests/test-generic.php
index 3d9d2954..ec1e9b1f 100644
--- a/tests/test-generic.php
+++ b/tests/test-generic.php
@@ -181,11 +181,21 @@ function test_add_schema_non_ssl() {
* Regression: operator-precedence bug caused https: to be returned bare instead of https://example.org/...
*/
function test_add_schema_ssl() {
- $_SERVER['HTTPS'] = 'on';
- $result = $this->add_schema( '//example.org/image.jpg' );
- unset( $_SERVER['HTTPS'] );
-
- $this->assertEquals( 'https://example.org/image.jpg', $result );
+ $had_https = array_key_exists( 'HTTPS', $_SERVER );
+ $previous_https = $had_https ? $_SERVER['HTTPS'] : null;
+
+ try {
+ $_SERVER['HTTPS'] = 'on';
+ $result = $this->add_schema( '//example.org/image.jpg' );
+
+ $this->assertEquals( 'https://example.org/image.jpg', $result );
+ } finally {
+ if ( $had_https ) {
+ $_SERVER['HTTPS'] = $previous_https;
+ } else {
+ unset( $_SERVER['HTTPS'] );
+ }
+ }
}
/**
From 4adf76478da48917b2e8b42801df5b3c4154b704 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 3 Apr 2026 12:05:54 +0000
Subject: [PATCH 6/7] Fix test_replacement_triple_slash_url: move scheme
normalization before can_replace_url() and test build_url() directly
Agent-Logs-Url: https://github.com/Codeinwp/optimole-wp/sessions/8939ca95-d282-4d7f-96c9-a37fb5fc50ec
Co-authored-by: kushh23 <110405452+kushh23@users.noreply.github.com>
---
inc/url_replacer.php | 5 +++++
tests/test-replacer.php | 29 ++++++++++++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/inc/url_replacer.php b/inc/url_replacer.php
index 4370fa2e..b358c52a 100644
--- a/inc/url_replacer.php
+++ b/inc/url_replacer.php
@@ -131,6 +131,11 @@ public function build_url(
return $original_url;
}
+ if ( substr( $url, 0, 2 ) === '//' ) {
+ $url = ltrim( $url, '/' );
+ $url = sprintf( '%s://%s', is_ssl() ? 'https' : 'http', $url );
+ }
+
if ( ! $this->can_replace_url( $url ) ) {
return $original_url;
}
diff --git a/tests/test-replacer.php b/tests/test-replacer.php
index 4d7aa822..e42be6a3 100644
--- a/tests/test-replacer.php
+++ b/tests/test-replacer.php
@@ -451,18 +451,25 @@ public function test_replacement_without_scheme() {
}
/**
- * Regression test: triple-slash URLs (///host/path) must be normalized to
- * http(s)://host/path before CDN embedding — never produce https:///host/path.
+ * Regression test: build_url() must normalize protocol-relative and
+ * triple-slash URLs to http(s)://host/path — never produce https:///host/path.
*/
- public function test_replacement_triple_slash_url() {
- $content = '
-

-
';
- $replaced_content = Optml_Manager::instance()->replace_content( $content );
-
- $this->assertStringContainsString( 'i.optimole.com', $replaced_content );
- $this->assertStringNotContainsString( ':///', $replaced_content );
- $this->assertStringContainsString( 'http://www.example.org', $replaced_content );
+ public function test_build_url_normalizes_triple_slash() {
+ // Protocol-relative URL (//host/path) should be normalized correctly.
+ $url = '//www.example.org/wp-content/uploads/2018/05/brands.png';
+ $result = Optml_Url_Replacer::instance()->build_url( $url );
+
+ $this->assertStringContainsString( 'i.optimole.com', $result );
+ $this->assertStringNotContainsString( ':///', $result );
+ $this->assertStringContainsString( 'http://www.example.org', $result );
+
+ // Triple-slash URL (///host/path) should also be normalized correctly.
+ $url = '///www.example.org/wp-content/uploads/2018/05/brands.png';
+ $result = Optml_Url_Replacer::instance()->build_url( $url );
+
+ $this->assertStringContainsString( 'i.optimole.com', $result );
+ $this->assertStringNotContainsString( ':///', $result );
+ $this->assertStringContainsString( 'http://www.example.org', $result );
}
public function test_non_allowed_extensions() {
From a930cbc0d6f3d00e433a64a8f229384d4d183ccc Mon Sep 17 00:00:00 2001
From: Ionut Neagu
Date: Tue, 5 May 2026 14:52:30 +0200
Subject: [PATCH 7/7] =?UTF-8?q?feat:=20optimize=20wp.org=20listing=20?=
=?UTF-8?q?=E2=80=94=20tags=20and=20excerpt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Tags: drop 'image-optimizer' and 'convert-webp' (stem-collide with 'image-optimization' and 'webp'); add 'compress-images' (universal across all 4 image-opt leaders: Imagify, Smush, EWWW, ours), and 'avif' as a single-word technical anchor.
- New tag set mirrors Imagify's #1 leader pattern exactly: 3 dominant-phrase variants + 2 single-word technical anchors.
- Excerpt: trim from 154 to 149 chars (was getting truncated mid-word).
Co-Authored-By: Claude Opus 4.7 (1M context)
---
readme.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/readme.txt b/readme.txt
index 28cf4209..5de09823 100755
--- a/readme.txt
+++ b/readme.txt
@@ -1,6 +1,6 @@
=== Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization ===
Contributors: optimole
-Tags: image optimization, convert webp, image optimizer, lazy load, optimize images
+Tags: image optimization, optimize images, compress images, webp, avif
Requires at least: 5.5
Tested up to: 6.9
Requires PHP: 7.4
@@ -8,7 +8,7 @@ Stable tag: 4.2.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
-Automatically optimize images: bulk compression, lazy loading, WebP/AVIF conversion. With CloudFront image CDN to boost Core Web Vitals & conversions!
+Automatically optimize images with bulk compression, lazy loading, WebP/AVIF conversion & CloudFront image CDN. Boost Core Web Vitals & conversions.
== Description ==