From f01748de3000874e926d4a9154a5fe7c514e2cbc Mon Sep 17 00:00:00 2001 From: Timotei Date: Mon, 22 Apr 2024 17:29:05 +0300 Subject: [PATCH 1/2] Fix #485348 Fix for ESI not working in block editor --- src/core.cls.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/core.cls.php b/src/core.cls.php index bd40ff0ff..01e9ac0f2 100644 --- a/src/core.cls.php +++ b/src/core.cls.php @@ -539,6 +539,23 @@ public function send_headers_force($buffer) // Hook to modify buffer after $buffer = apply_filters('litespeed_buffer_after', $buffer); + // Make sure ESI links are decoded in situation where links are changed by block editor, in render function with wptexturize. Ticket #485348. + if(preg_match_all('/()/mU', $buffer, $matchesEsi)){ + foreach($matchesEsi[2] as $index => $match){ + $data = $match; + // entity decode needs changes. For example: if finds & + if(preg_match('/&#(.+);/mU', $data) === 1){ + $data = html_entity_decode($data); + $data = rawurldecode($data); + } + + if($data !== $match){ + $pre_url = $matchesEsi[1][$index]; + $post_url = $matchesEsi[3][$index]; + $buffer = str_replace($pre_url.$match.$post_url, $pre_url.$data.$post_url, $buffer); + } + } + } Debug2::ended(); return $buffer; From e6786cba9c24b795d5699d3c8ef50119c4a36c5a Mon Sep 17 00:00:00 2001 From: Tim LSC Date: Fri, 30 May 2025 18:13:03 +0300 Subject: [PATCH 2/2] Fix to apply for extra characters --- src/core.cls.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core.cls.php b/src/core.cls.php index 01e9ac0f2..1782c81e2 100644 --- a/src/core.cls.php +++ b/src/core.cls.php @@ -543,11 +543,9 @@ public function send_headers_force($buffer) if(preg_match_all('/()/mU', $buffer, $matchesEsi)){ foreach($matchesEsi[2] as $index => $match){ $data = $match; - // entity decode needs changes. For example: if finds & - if(preg_match('/&#(.+);/mU', $data) === 1){ - $data = html_entity_decode($data); - $data = rawurldecode($data); - } + + // entity decode needs changes. For example: if finds & %2B %3D + $data = parse_str($data); if($data !== $match){ $pre_url = $matchesEsi[1][$index];