From 4604c37a1db0a46881b8c1f390734f595141b65d Mon Sep 17 00:00:00 2001 From: Stefan Pasch Date: Tue, 24 Sep 2024 17:04:18 +0200 Subject: [PATCH 1/3] Replace deprecated utf8_decode with mb_convert_encoding --- inc/namespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/namespace.php b/inc/namespace.php index c05bbc9..115493c 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -432,7 +432,7 @@ function add_anchor_attribute( string $html ): string { } // Save the HTML changes. - $content = utf8_decode( $dom->saveHTML( $dom->documentElement ) ); //phpcs:ignore + $content = mb_convert_encoding( $dom->saveHTML( $dom->documentElement ), 'ISO-8859-1', 'UTF-8'); //phpcs:ignore return $content; } From f1b3d694d0b257fbdd02b549f558b07934a2ef22 Mon Sep 17 00:00:00 2001 From: Stefan Pasch Date: Tue, 24 Sep 2024 17:12:12 +0200 Subject: [PATCH 2/3] CS --- inc/namespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/namespace.php b/inc/namespace.php index 115493c..ce9bc41 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -432,7 +432,7 @@ function add_anchor_attribute( string $html ): string { } // Save the HTML changes. - $content = mb_convert_encoding( $dom->saveHTML( $dom->documentElement ), 'ISO-8859-1', 'UTF-8'); //phpcs:ignore + $content = mb_convert_encoding( $dom->saveHTML( $dom->documentElement ), 'ISO-8859-1', 'UTF-8' ); //phpcs:ignore return $content; } From 7fa6440d03da6ff4653e51d4fe7bb2f23b3ec219 Mon Sep 17 00:00:00 2001 From: Stefan Pasch Date: Tue, 24 Sep 2024 17:22:19 +0200 Subject: [PATCH 3/3] Switched utf8 encoding like upstream --- inc/namespace.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/namespace.php b/inc/namespace.php index ce9bc41..2c2904d 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -407,7 +407,7 @@ function add_anchor_attribute( string $html ): string { libxml_use_internal_errors( true ); $dom = new \DOMDocument(); - $dom->loadHTML( $html_wo_nbs, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD ); + $dom->loadHTML( '' . "\n" . $html_wo_nbs, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD ); // use xpath to select the Heading html tags. $xpath = new \DOMXPath( $dom ); @@ -432,7 +432,7 @@ function add_anchor_attribute( string $html ): string { } // Save the HTML changes. - $content = mb_convert_encoding( $dom->saveHTML( $dom->documentElement ), 'ISO-8859-1', 'UTF-8' ); //phpcs:ignore + $content = $dom->saveHTML( $dom->documentElement ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase return $content; }