From b0d45237bd143ae6b0a77859346db76eb9915b21 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 1 May 2024 16:46:28 +0200 Subject: [PATCH 1/2] FIX: Better HTML decoding support See further: - https://developer.wordpress.org/reference/functions/wp_specialchars_decode/ - https://meta.discourse.org/t/ampersands-getting-over-escaped-going-from-wordpress-to-discourse/300004/7?u=angus --- lib/discourse-publish.php | 2 +- tests/phpunit/test-discourse-publish.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/discourse-publish.php b/lib/discourse-publish.php index 6370819a..3bae97a2 100644 --- a/lib/discourse-publish.php +++ b/lib/discourse-publish.php @@ -846,7 +846,7 @@ protected function get_excluded_tag_slugs() { * @return string */ protected function sanitize_title( $title ) { - return wp_specialchars_decode( wp_strip_all_tags( $title ) ); + return html_entity_decode( wp_strip_all_tags( $title ), ENT_COMPAT, 'UTF-8' ); } /** diff --git a/tests/phpunit/test-discourse-publish.php b/tests/phpunit/test-discourse-publish.php index 14722a48..73b60c40 100644 --- a/tests/phpunit/test-discourse-publish.php +++ b/tests/phpunit/test-discourse-publish.php @@ -858,8 +858,8 @@ public function test_force_publish_max_age_prevents_older_posts_from_being_publi * Test that HTML entities are converted to their special characters. */ public function test_conversion_of_html_entities_in_title() { - $title_with_entities = 'Title with &'; - $title_with_decoded_entities = 'Title with &'; + $title_with_entities = 'Title with & and –'; + $title_with_decoded_entities = 'Title with & and –'; self::$post_atts['post_title'] = $title_with_entities; $response = $this->build_response( 'success' ); From 791105efa8ef8a3c30d59edcd2bfd64a6382b485 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 1 May 2024 16:51:07 +0200 Subject: [PATCH 2/2] Two Five Three --- readme.txt | 6 +++++- wp-discourse.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 27189e51..8aeb6594 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: discourse, forum, comments, sso Requires at least: 5.1 Tested up to: 6.4 Requires PHP: 5.6 -Stable tag: 2.5.2 +Stable tag: 2.5.3 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -123,6 +123,10 @@ To create a coherent top menu, see our tutorial on how to make a [Custom nav hea == Changelog == +#### 2.5.3 01/05/2024 + +- Improve HTML entites decoding in titles. + #### 2.5.2 08/04/2024 - Add a 'Disable user creation' setting for the DiscourseConnect Client. diff --git a/wp-discourse.php b/wp-discourse.php index 23c120a3..f8a5938a 100644 --- a/wp-discourse.php +++ b/wp-discourse.php @@ -2,7 +2,7 @@ /** * Plugin Name: WP-Discourse * Description: Use Discourse as a community engine for your WordPress blog - * Version: 2.5.2 + * Version: 2.5.3 * Requires at least: 5.1 * Requires PHP: 5.6 * Author: Discourse @@ -36,7 +36,7 @@ define( 'WPDISCOURSE_URL', plugins_url( '', __FILE__ ) ); define( 'MIN_WP_VERSION', '4.7' ); define( 'MIN_PHP_VERSION', '5.6.0' ); -define( 'WPDISCOURSE_VERSION', '2.5.2' ); +define( 'WPDISCOURSE_VERSION', '2.5.3' ); define( 'WPDISCOURSE_LOGO_URL', WPDISCOURSE_PATH . 'assets/icon.svg' ); $base64 = base64_encode( file_get_contents( WPDISCOURSE_LOGO_URL ) ); define( 'WPDISCOURSE_LOGO', "data:image/svg+xml;base64,$base64" );