From 3e3c1a6abe8903d61a46e8b3fff87dd44f712959 Mon Sep 17 00:00:00 2001 From: colemanw Date: Thu, 15 Feb 2024 11:42:33 -0500 Subject: [PATCH] Afform - Fix incorrect html encoding when saving Fixes https://lab.civicrm.org/dev/core/-/issues/4977 This reverts 0ae1b99 AND 4a439e7 back to the original version which used a simple str_replace. The problem with 4a439e7 is that function mode is deprecated in php 8.2. The problem with 0ae1b99 is that it was wrong and broke the html encoding of the file. So this takes us all the way back to the original version of the function, which worked fine for what it did. --- ext/afform/core/CRM/Afform/ArrayHtml.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/afform/core/CRM/Afform/ArrayHtml.php b/ext/afform/core/CRM/Afform/ArrayHtml.php index 6c942b2ecc..14fc62fbe8 100644 --- a/ext/afform/core/CRM/Afform/ArrayHtml.php +++ b/ext/afform/core/CRM/Afform/ArrayHtml.php @@ -376,7 +376,10 @@ class CRM_Afform_ArrayHtml { * @return string */ public function replaceUnicodeChars($markup) { - return htmlspecialchars_decode(htmlentities($markup, ENT_COMPAT, 'utf-8', FALSE)); + $replace = [ + ["\xc2\xa0", ' '], + ]; + return str_replace(array_column($replace, 0), array_column($replace, 1), $markup); } /** -- 2.25.1