From d7e5705520a13406951f862e3d420a9e9a975edd Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Fri, 12 Aug 2022 17:50:14 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B05318=20-=20Fix=20DBObject::CheckValue()?= =?UTF-8?q?=20messages=20being=20HTML=20encoded=20when=20not=20necessary?= =?UTF-8?q?=20(#326)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rollback N°4898 - Security fix * N°5318 - security fix --- application/cmdbabstract.class.inc.php | 6 +++++- core/coreexception.class.inc.php | 16 ++++++---------- core/dbobject.class.php | 12 ++++++------ pages/UI.php | 5 ++++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 1139a08df..9f4188c18 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -4735,11 +4735,15 @@ EOF $sCSSClass = $bResult ? HILIGHT_CLASS_NONE : HILIGHT_CLASS_CRITICAL; $sChecked = $bResult ? 'checked' : ''; $sDisabled = $bResult ? '' : 'disabled'; + + $aErrorsToDisplay = array_map(function($sError) { + return utils::HtmlEntities($sError); + }, $aErrors); $aRows[] = array( 'form::select' => "", 'object' => $oObj->GetHyperlink(), 'status' => $sStatus, - 'errors' => '
'.($bResult ? '' : implode('
', $aErrors)).'
', + 'errors' => ''.($bResult ? '' : implode('
', $aErrorsToDisplay)).'
', '@class' => $sCSSClass, ); if ($bResult && (!$bPreview)) diff --git a/core/coreexception.class.inc.php b/core/coreexception.class.inc.php index a85417786..b29ece9b1 100644 --- a/core/coreexception.class.inc.php +++ b/core/coreexception.class.inc.php @@ -165,19 +165,15 @@ class CoreCannotSaveObjectException extends CoreException public function getHtmlMessage() { $sTitle = Dict::S('UI:Error:SaveFailed'); - $sContent = "{$sTitle}"; + $sContent = "".utils::HtmlEntities($sTitle).""; - if (count($this->aIssues) == 1) - { + if (count($this->aIssues) == 1) { $sIssue = reset($this->aIssues); - $sContent .= " {$sIssue}"; - } - else - { + $sContent .= " ".utils::HtmlEntities($sIssue).""; + } else { $sContent .= ''.implode('
',$aErrors)."\n"; + $aErrorsToDisplay = array_map(function($sError) { + return utils::HtmlEntities($sError); + }, $aErrors); + $sError = ''.implode('
',$aErrorsToDisplay)."\n"; } } else