From 93aee5883bcf84b4f11740a58c5b17cfc9713cb6 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 23 Feb 2023 15:17:46 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B06020=20New=20\utils::EscapedHtmlDecode?= =?UTF-8?q?=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 439b565f3..dc2f2d1d8 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1864,20 +1864,37 @@ class utils return html_entity_decode($sValue, ENT_QUOTES, 'UTF-8'); } + /** + * @param string $sValue value encoded with {@see self::EscapeHtml()} + * + * @return string decoded value + * + * @uses \htmlspecialchars_decode() + * @link https://www.php.net/manual/en/function.htmlspecialchars-decode.php + * @since 3.0.3 3.1.0 N°6020 method creation + */ + public static function EscapedHtmlDecode($sValue) + { + return htmlspecialchars_decode( + $sValue, + ENT_QUOTES | ENT_DISALLOWED | ENT_HTML5 + ); + } + /** * Convert a string containing some (valid) HTML markup to plain text + * * @param string $sHtml + * * @return string */ public static function HtmlToText($sHtml) { - try - { + try { //return ''.$sHtml; return \Html2Text\Html2Text::convert(''.$sHtml); } - catch(Exception $e) - { + catch (Exception $e) { return $e->getMessage(); } }