Skip to content

Commit e4c2b25

Browse files
Fix ESI shortcodes in block editor
1 parent cca7f6e commit e4c2b25

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/core.cls.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,20 @@ public function send_headers_force( $buffer ) {
529529
// Hook to modify buffer after
530530
$buffer = apply_filters( 'litespeed_buffer_after', $buffer );
531531

532+
// Make sure ESI links are decoded in situation where links are changed by block editor, in render function with wptexturize. Ticket #485348.
533+
if ( preg_match_all ( '/(<esi.+src=["\'])(.*)(["\'].*\/>)/mU', $buffer, $matches_esi ) ) {
534+
foreach ( $matches_esi[2] as $index => $match ) {
535+
// entity decode needs changes. For example: if finds &#038; %2B %3D
536+
$data = htmlspecialchars_decode($match);
537+
538+
if ( $data !== $match ) {
539+
$pre_url = $matches_esi[1][$index];
540+
$post_url = $matches_esi[3][$index];
541+
$buffer = str_replace( $pre_url . $match . $post_url, $pre_url . $data . $post_url, $buffer );
542+
}
543+
}
544+
}
545+
532546
Debug2::ended();
533547

534548
return $buffer;

0 commit comments

Comments
 (0)