From 926697d183b53a87d643569dc9df98507aab4439 Mon Sep 17 00:00:00 2001 From: jf-cbd Date: Fri, 14 Aug 2026 10:39:42 +0200 Subject: [PATCH] Rollback after reading HTML so it can throw error later in the PHP execution if needed --- application/utils.inc.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 8e769d17a..dfcfd07ef 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -3038,9 +3038,14 @@ TXT $aMentionedObjects = []; $aMentionAllowedClasses = MetaModel::GetConfig()->Get('mentions.allowed_classes'); $oDom = new \DOMDocument(); - libxml_use_internal_errors(true); // to keep processing even in case of "invalid" HTML, cf. testGetMentionedObjectsFromText - $oDom->loadHTML(''.$sText); + $bPreviousUseInternalErrors = libxml_use_internal_errors(true); // to keep processing even in case of "invalid" HTML, cf. testGetMentionedObjectsFromText + try { + $oDom->loadHTML(''.$sText); + } finally { + libxml_clear_errors(); + libxml_use_internal_errors($bPreviousUseInternalErrors); + } $oXpath = new \DOMXPath($oDom); $oNodes = $oXpath->query('//a[@data-object-class and @data-object-key]');