diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index c6b1ca722..9d1c771be 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -124,7 +124,7 @@ class URP_Profiles extends UserRightsBaseClassGUI $bGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode); if ($bGrant === true) { - $aStimuli[] = ''.htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8').''; + $aStimuli[] = ''.utils::EscapeHtml($oStimulus->GetLabel()).''; } } $sStimuli = implode(', ', $aStimuli); diff --git a/addons/userrights/userrightsprofile.db.class.inc.php b/addons/userrights/userrightsprofile.db.class.inc.php index 44b40ab30..10fc826d9 100644 --- a/addons/userrights/userrightsprofile.db.class.inc.php +++ b/addons/userrights/userrightsprofile.db.class.inc.php @@ -278,8 +278,8 @@ class URP_Profiles extends UserRightsBaseClassGUI { $oGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode); if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes')) - { - $aStimuli[] = ''.htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8').''; + { + $aStimuli[] = ''.utils::EscapeHtml($oStimulus->GetLabel()).''; } } $sStimuli = implode(', ', $aStimuli); diff --git a/addons/userrights/userrightsprojection.class.inc.php b/addons/userrights/userrightsprojection.class.inc.php index 6aa5eefc0..84f239c52 100644 --- a/addons/userrights/userrightsprojection.class.inc.php +++ b/addons/userrights/userrightsprojection.class.inc.php @@ -110,8 +110,8 @@ class URP_Profiles extends UserRightsBaseClass { $oGrant = $oUserRights->GetClassStimulusGrant($this->GetKey(), $sClass, $sStimulusCode); if (is_object($oGrant) && ($oGrant->Get('permission') == 'yes')) - { - $aStimuli[] = ''.htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8').''; + { + $aStimuli[] = ''.utils::EscapeHtml($oStimulus->GetLabel()).''; } } $sStimuli = implode(', ', $aStimuli); diff --git a/application/applicationcontext.class.inc.php b/application/applicationcontext.class.inc.php index 1361f92d3..903fa2cee 100644 --- a/application/applicationcontext.class.inc.php +++ b/application/applicationcontext.class.inc.php @@ -224,7 +224,7 @@ class ApplicationContext { $sContext = ""; foreach ($this->aValues as $sName => $sValue) { - $sContext .= "\n"; + $sContext .= "\n"; } return $sContext; } @@ -238,7 +238,7 @@ class ApplicationContext { $aContextInputBlocks = []; foreach ($this->aValues as $sName => $sValue) { - $aContextInputBlocks[] = InputUIBlockFactory::MakeForHidden("c[$sName]", htmlentities($sValue, ENT_QUOTES, 'UTF-8')); + $aContextInputBlocks[] = InputUIBlockFactory::MakeForHidden("c[$sName]", utils::EscapeHtml($sValue)); } return $aContextInputBlocks; } diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index efc31737b..8aa96b247 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -987,10 +987,8 @@ HTML $this->GetSynchroReplicaFlags($sAttCode, $aReasons); $sTip = ''; foreach ($aReasons as $aRow) { - $sDescription = htmlentities($aRow['description'], ENT_QUOTES, - 'UTF-8'); - $sDescription = str_replace(array("\r\n", "\n"), "
", - $sDescription); + $sDescription = utils::EscapeHtml($aRow['description']); + $sDescription = str_replace(array("\r\n", "\n"), "
", $sDescription); $sTip .= "
"; $sTip .= "
Synchronized with {$aRow['name']}
"; $sTip .= "
$sDescription
"; @@ -1403,7 +1401,7 @@ HTML } else { if ($oAttDef instanceof AttributeCaseLog) { $rawValue = $oObj->Get($sAttCodeEx); - $outputValue = str_replace("\n", "
", htmlentities($rawValue->__toString(), ENT_QUOTES, 'UTF-8')); + $outputValue = str_replace("\n", "
", utils::EscapeHtml($rawValue->__toString())); // Trick for Excel: treat the content as text even if it begins with an equal sign $aRow[$oAttDef->GetCode()] = $outputValue; } else { @@ -1417,9 +1415,9 @@ HTML } } if ($bLocalize) { - $outputValue = htmlentities($oFinalAttDef->GetEditValue($rawValue), ENT_QUOTES, 'UTF-8'); + $outputValue = utils::EscapeHtml($oFinalAttDef->GetEditValue($rawValue)); } else { - $outputValue = htmlentities($rawValue, ENT_QUOTES, 'UTF-8'); + $outputValue = utils::EscapeHtml($rawValue); } $aRow[$oAttDef->GetCode()] = $outputValue; } @@ -1895,7 +1893,7 @@ HTML { $rawValue = $oObj->Get($sAttCodeEx); $outputValue = str_replace("\n", "
", - htmlentities($rawValue->__toString(), ENT_QUOTES, 'UTF-8')); + utils::EscapeHtml($rawValue->__toString())); // Trick for Excel: treat the content as text even if it begins with an equal sign $aRow[] = ''.$outputValue.''; } @@ -1912,14 +1910,11 @@ HTML $rawValue = ''; } } - if ($bLocalize) - { - $outputValue = htmlentities($oFinalAttDef->GetEditValue($rawValue), ENT_QUOTES, - 'UTF-8'); + if ($bLocalize) { + $outputValue = utils::EscapeHtml($oFinalAttDef->GetEditValue($rawValue)); } - else - { - $outputValue = htmlentities($rawValue, ENT_QUOTES, 'UTF-8'); + else { + $outputValue = utils::EscapeHtml($rawValue); } $aRow[] = ''.$outputValue.''; } @@ -2156,7 +2151,7 @@ HTML; $sHours = ""; $sMinutes = ""; $sSeconds = ""; - $sHidden = ""; + $sHidden = ""; $sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, $sSeconds).$sHidden." ".$sValidationSpan.$sReloadSpan; $oPage->add_ready_script("$('#{$iId}').on('update', function(evt, sFormId) { return ToggleDurationField('$iId'); });"); break; @@ -2166,8 +2161,7 @@ HTML; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; - $sHTMLValue = "
{$sValidationSpan}{$sReloadSpan}"; + $sHTMLValue = "
{$sValidationSpan}{$sReloadSpan}"; break; case 'OQLExpression': @@ -2319,13 +2313,13 @@ EOF $sHeader = '
'; // will be hidden in CSS (via :empty) if it remains empty $sEditValue = is_object($value) ? $value->GetModifiedEntry('html') : ''; - $sPreviousLog = is_object($value) ? $value->GetAsHTML($oPage, true /* bEditMode */, array('AttributeText', 'RenderWikiHtml')) : ''; + $sPreviousLog = is_object($value) ? $value->GetAsHTML($oPage, true /* bEditMode */, array('AttributeText', 'RenderWikiHtml')) : ''; $iEntriesCount = is_object($value) ? count($value->GetIndex()) : 0; $sHidden = ""; // To know how many entries the case log already contains $sHTMLValue = "$sHeader
"; - $sHTMLValue .= ""; - $sHTMLValue .= "$sPreviousLog
{$sValidationSpan}{$sReloadSpan}$sHidden"; + $sHTMLValue .= ""; + $sHTMLValue .= "$sPreviousLog
{$sValidationSpan}{$sReloadSpan}$sHidden"; // Note: This should be refactored for all types of attribute (see at the end of this function) but as we are doing this for a maintenance release, we are scheduling it for the next main release in to order to avoid regressions as much as possible. $sNullValue = $oAttDef->GetNullValue(); @@ -2570,16 +2564,16 @@ JS case 'Set': case 'TagSet': - $sInputType = self::ENUM_INPUT_TYPE_TAGSET; - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/selectize.min.js'); - $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css'); - $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.itop-set-widget.js'); + $sInputType = self::ENUM_INPUT_TYPE_TAGSET; + $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/selectize.min.js'); + $oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css'); + $oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.itop-set-widget.js'); - $oPage->add_dict_entry('Core:AttributeSet:placeholder'); + $oPage->add_dict_entry('Core:AttributeSet:placeholder'); - /** @var \ormSet $value */ + /** @var \ormSet $value */ $sJson = $oAttDef->GetJsonForWidget($value, $aArgs); - $sEscapedJson = htmlentities($sJson, ENT_QUOTES, 'UTF-8'); + $sEscapedJson = utils::EscapeHtml($sJson); $sSetInputName = "attr_{$sFormPrefix}{$sAttCode}"; // handle form validation @@ -3692,8 +3686,7 @@ HTML; break; default: - $oPage->add("
".htmlentities(MyHelpers::beautifulstr($data, 1000, true), ENT_QUOTES,
-								'UTF-8')."
\n"); + $oPage->add("
".utils::EscapeHtml(MyHelpers::beautifulstr($data, 1000, true))."
\n"); } break; @@ -4734,9 +4727,8 @@ HTML; { $aReasons = array(); $sTip = ''; - foreach($aReasons as $aRow) - { - $sDescription = htmlentities($aRow['description'], ENT_QUOTES, 'UTF-8'); + foreach($aReasons as $aRow) { + $sDescription = utils::EscapeHtml($aRow['description']); $sDescription = str_replace(array("\r\n", "\n"), "
", $sDescription); $sTip .= "
"; $sTip .= "
Synchronized with {$aRow['name']}
"; @@ -4748,8 +4740,7 @@ HTML; // Attribute is read-only $sHTMLValue = $this->GetAsHTML($sAttCode); - $sHTMLValue .= ''; + $sHTMLValue .= ''; $aFieldsMap[$sAttCode] = $sInputId; } else diff --git a/application/forms.class.inc.php b/application/forms.class.inc.php index a2cee1598..3a720c39b 100644 --- a/application/forms.class.inc.php +++ b/application/forms.class.inc.php @@ -838,7 +838,8 @@ class DesignerFormField { $sId = $this->oForm->GetFieldId($this->sCode); $sName = $this->oForm->GetFieldName($this->sCode); - return array('label' => $this->sLabel, 'value' => "defaultValue, ENT_QUOTES, 'UTF-8')."\">"); + + return array('label' => $this->sLabel, 'value' => "defaultValue)."\">"); } /** @@ -1012,9 +1013,8 @@ class DesignerTextField extends DesignerFormField $sId = $this->oForm->GetFieldId($this->sCode); $sName = $this->oForm->GetFieldName($this->sCode); - if ($this->IsReadOnly()) - { - $sHtmlValue = "".htmlentities($this->defaultValue, ENT_QUOTES, 'UTF-8')."defaultValue, ENT_QUOTES, 'UTF-8')."\"/>"; + if ($this->IsReadOnly()) { + $sHtmlValue = "".utils::EscapeHtml($this->defaultValue)."defaultValue)."\"/>"; } else { @@ -1038,11 +1038,10 @@ $('#$sId').on('change keyup validate', function() { ValidateWithPattern('$sId', EOF ); $sCSSClasses = ''; - if (count($this->aCSSClasses) > 0) - { + if (count($this->aCSSClasses) > 0) { $sCSSClasses = 'class="'.implode(' ', $this->aCSSClasses).'"'; } - $sHtmlValue = "defaultValue, ENT_QUOTES, 'UTF-8')."\">"; + $sHtmlValue = "defaultValue)."\">"; } return array('label' => $this->sLabel, 'value' => $sHtmlValue); } @@ -1101,10 +1100,9 @@ class DesignerLongTextField extends DesignerTextField { $sCSSClasses = 'class="'.implode(' ', $this->aCSSClasses).'"'; } - if (!$this->IsReadOnly()) - { + if (!$this->IsReadOnly()) { $oP->add_ready_script( -<<".htmlentities($this->defaultValue, ENT_QUOTES, 'UTF-8').""; + $sValue = ""; } - else - { - $sValue = "
".htmlentities($this->defaultValue, ENT_QUOTES, 'UTF-8')."
"; + else { + $sValue = "
".utils::EscapeHtml($this->defaultValue)."
"; } return array('label' => $this->sLabel, 'value' => $sValue); } @@ -1145,9 +1142,8 @@ class DesignerIntegerField extends DesignerFormField $sId = $this->oForm->GetFieldId($this->sCode); $sName = $this->oForm->GetFieldName($this->sCode); - if ($this->IsReadOnly()) - { - $sHtmlValue = "".htmlentities($this->defaultValue, ENT_QUOTES, 'UTF-8')."defaultValue, ENT_QUOTES, 'UTF-8')."\"/>"; + if ($this->IsReadOnly()) { + $sHtmlValue = "".utils::EscapeHtml($this->defaultValue)."defaultValue)."\"/>"; } else { @@ -1164,11 +1160,10 @@ $('#$sId').on('change keyup validate', function() { ValidateInteger('$sId', $sMa EOF ); $sCSSClasses = ''; - if (count($this->aCSSClasses) > 0) - { + if (count($this->aCSSClasses) > 0) { $sCSSClasses = 'class="'.implode(' ', $this->aCSSClasses).'"'; } - $sHtmlValue = "defaultValue, ENT_QUOTES, 'UTF-8')."\">"; + $sHtmlValue = "defaultValue)."\">"; } return array('label' => $this->sLabel, 'value' => $sHtmlValue); } @@ -1289,22 +1284,18 @@ class DesignerComboField extends DesignerFormField { if ($this->bMultipleSelection) { - if(in_array($sKey, $this->defaultValue)) - { + if(in_array($sKey, $this->defaultValue)) { $aSelected[] = $sDisplayValue; - $aHiddenValues[] = ""; + $aHiddenValues[] = ""; } - } - else - { - if ($sKey == $this->defaultValue) - { + } else { + if ($sKey == $this->defaultValue) { $aSelected[] = $sDisplayValue; - $aHiddenValues[] = ""; + $aHiddenValues[] = ""; } } } - $sHtml = "".htmlentities(implode(', ', $aSelected), ENT_QUOTES, 'UTF-8').implode($aHiddenValues).""; + $sHtml = "".utils::EscapeHtml(implode(', ', $aSelected)).implode($aHiddenValues).""; } else { @@ -1328,7 +1319,7 @@ class DesignerComboField extends DesignerFormField } // Quick and dirty: display the menu parents as a tree $sHtmlValue = str_replace(' ', ' ', $sDisplayValue); - $sHtml .= ""; + $sHtml .= ""; } $sHtml .= ""; if ($this->bOtherChoices) @@ -1379,10 +1370,9 @@ class DesignerBooleanField extends DesignerFormField $sId = $this->oForm->GetFieldId($this->sCode); $sName = $this->oForm->GetFieldName($this->sCode); $sChecked = $this->defaultValue ? 'checked' : ''; - if ($this->IsReadOnly()) - { + if ($this->IsReadOnly()) { $sLabel = $this->defaultValue ? Dict::S('UI:UserManagement:ActionAllowed:Yes') : Dict::S('UI:UserManagement:ActionAllowed:No'); //TODO use our own yes/no translations - $sHtmlValue = "".htmlentities($sLabel)."defaultValue, ENT_QUOTES, 'UTF-8')."\"/>"; + $sHtmlValue = "".utils::EscapeHtml($sLabel)."defaultValue)."\"/>"; } else { @@ -1518,7 +1508,7 @@ class DesignerIconSelectionField extends DesignerFormField EOF ); } else { - $sValue = ' '.htmlentities($this->aAllowedValues[$idx]['label'], ENT_QUOTES, 'UTF-8').''; + $sValue = ' '.utils::EscapeHtml($this->aAllowedValues[$idx]['label']).''; } $sReadOnly = $this->IsReadOnly() ? 'disabled' : ''; return array('label' => $this->sLabel, 'value' => $sValue); @@ -1665,14 +1655,14 @@ class DesignerSortableField extends DesignerFormField $sId = $this->oForm->GetFieldId($this->sCode); $sName = $this->oForm->GetFieldName($this->sCode); $sReadOnly = $this->IsReadOnly() ? 'readonly="readonly"' : ''; - $aResult = array('label' => $this->sLabel, 'value' => "defaultValue, ENT_QUOTES, 'UTF-8')."\">"); - + $aResult = array('label' => $this->sLabel, 'value' => "defaultValue)."\">"); + $sJSFields = json_encode(array_keys($this->aAllowedValues)); $oP->add_ready_script( "$('#$sId').sortable_field({aAvailableFields: $sJSFields});" ); - + return $aResult; } } @@ -1761,8 +1751,8 @@ class DesignerFormSelectorField extends DesignerFormField foreach ($this->aSubForms as $iKey => $aFormData) { if ($iKey == $this->defaultValue) // Default value is actually the index { - $sDisplayValue = htmlentities($aFormData['label'], ENT_QUOTES, 'UTF-8'); - $sHiddenValue = ""; + $sDisplayValue = utils::EscapeHtml($aFormData['label']); + $sHiddenValue = ""; break; } } @@ -1770,8 +1760,8 @@ class DesignerFormSelectorField extends DesignerFormField } else { $sHtml = "'; + $sHTMLValue .= ''; $aFieldsMap[$sAttCode] = $iInputId; $aParams['this->comments('.$sAttCode.')'] = $sSynchroIcon; } diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 4f123fab2..c54cec21b 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -610,7 +610,7 @@ EOF $sHTMLValue .= "
iId}\" onClick=\"oACWidget_{$this->iId}.Search();\">
"; // another hidden input to store & pass the object's Id - $sHTMLValue .= "iId\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" value=\"".htmlentities($value, ENT_QUOTES, 'UTF-8')."\" />\n"; + $sHTMLValue .= "iId\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" value=\"".utils::EscapeHtml($value)."\" />\n"; $JSSearchMode = $this->bSearchMode ? 'true' : 'false'; // Scripts to start the autocomplete and bind some events to it @@ -962,7 +962,7 @@ HTML foreach (MetaModel::ListAttributeDefs($this->sTargetClass) as $sAttCode => $oAttDef) { if (($oAttDef instanceof AttributeBlob) || (false)) { $aFieldsFlags[$sAttCode] = OPT_ATT_READONLY; - $aFieldsComments[$sAttCode] = ' '; + $aFieldsComments[$sAttCode] = ' '; } } cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true, 'fieldsFlags' => $aFieldsFlags, 'fieldsComments' => $aFieldsComments)); diff --git a/application/ui.passwordwidget.class.inc.php b/application/ui.passwordwidget.class.inc.php index 16e333ab3..58aca4fa3 100644 --- a/application/ui.passwordwidget.class.inc.php +++ b/application/ui.passwordwidget.class.inc.php @@ -60,8 +60,8 @@ class UIPasswordWidget $sChangedValue = (($sPasswordValue != '*****') || ($sConfirmPasswordValue != '*****')) ? 1 : 0; $sHtmlValue = ''; $sHtmlValue .= '
'; - $sHtmlValue .= ''; - $sHtmlValue .= '
'; + $sHtmlValue .= ''; + $sHtmlValue .= '
'; $sHtmlValue .= '
'; $sHtmlValue .= ''; diff --git a/application/utils.inc.php b/application/utils.inc.php index cf972a9b7..2dc6333f1 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -813,21 +813,20 @@ class utils */ public static function StringToTime($sDate, $sFormat) { - // Source: http://php.net/manual/fr/function.strftime.php + // Source: http://php.net/manual/fr/function.strftime.php // (alternative: http://www.php.net/manual/fr/datetime.formats.date.php) static $aDateTokens = null; static $aDateRegexps = null; - if (is_null($aDateTokens)) - { - $aSpec = array( - '%d' =>'(?[0-9]{2})', + if (is_null($aDateTokens)) { + $aSpec = array( + '%d' => '(?[0-9]{2})', '%m' => '(?[0-9]{2})', '%y' => '(?[0-9]{2})', '%Y' => '(?[0-9]{4})', '%H' => '(?[0-2][0-9])', '%i' => '(?[0-5][0-9])', '%s' => '(?[0-5][0-9])', - ); + ); $aDateTokens = array_keys($aSpec); $aDateRegexps = array_values($aSpec); } @@ -1892,7 +1891,8 @@ class utils { $sText = str_replace("\r\n", "\n", $sText); $sText = str_replace("\r", "\n", $sText); - return str_replace("\n", '
', htmlentities($sText, ENT_QUOTES, 'UTF-8')); + + return str_replace("\n", '
', utils::EscapeHtml($sText)); } /** diff --git a/core/MyHelpers.class.inc.php b/core/MyHelpers.class.inc.php index f5260d987..d3f47be31 100644 --- a/core/MyHelpers.class.inc.php +++ b/core/MyHelpers.class.inc.php @@ -470,9 +470,9 @@ class Str public static function pure2html($pure, $maxLength = false) { // Check for HTML entities, but be careful the DB is in UTF-8 - return $maxLength - ? htmlentities(substr($pure, 0, $maxLength), ENT_QUOTES, 'UTF-8') - : htmlentities($pure, ENT_QUOTES, 'UTF-8'); + return $maxLength + ? utils::EscapeHtml(substr($pure, 0, $maxLength)) + : utils::EscapeHtml($pure); } public static function pure2sql($pure, $maxLength = false) { diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index f2931a08d..f55087dcb 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -12776,7 +12776,7 @@ class AttributeCustomFields extends AttributeDefinition $sRet = $value->GetAsHTML($bLocalize); } catch (Exception $e) { - $sRet = 'Custom field error: '.htmlentities($e->getMessage(), ENT_QUOTES, 'UTF-8'); + $sRet = 'Custom field error: '.utils::EscapeHtml($e->getMessage()); } return $sRet; diff --git a/core/cmdbchangeop.class.inc.php b/core/cmdbchangeop.class.inc.php index d4d90e308..516436093 100644 --- a/core/cmdbchangeop.class.inc.php +++ b/core/cmdbchangeop.class.inc.php @@ -875,7 +875,7 @@ class CMDBChangeOpSetAttributeCaseLog extends CMDBChangeOpSetAttribute */ protected function ToHtml($sRawText) { - return str_replace(array("\r\n", "\n", "\r"), "
", htmlentities($sRawText, ENT_QUOTES, 'UTF-8')); + return str_replace(array("\r\n", "\n", "\r"), "
", utils::EscapeHtml($sRawText)); } } @@ -1167,9 +1167,8 @@ class CMDBChangeOpSetAttributeCustomFields extends CMDBChangeOpSetAttribute $oHandler = $oAttDef->GetHandler($aValues); $sValueDesc = $oHandler->GetAsHTML($aValues); } - catch (Exception $e) - { - $sValueDesc = 'Custom field error: '.htmlentities($e->getMessage(), ENT_QUOTES, 'UTF-8'); + catch (Exception $e) { + $sValueDesc = 'Custom field error: '.utils::EscapeHtml($e->getMessage()); } $sTextView = '
'.$sValueDesc.'
'; diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 536d0946c..9111586cc 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1879,7 +1879,7 @@ class Config { // Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack) throw new ConfigException('Syntax error in configuration file', - array('file' => $sConfigFile, 'error' => ''.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').'')); + array('file' => $sConfigFile, 'error' => ''.utils::EscapeHtml($sNoise, ENT_QUOTES).'')); } if (!isset($MySettings) || !is_array($MySettings)) diff --git a/core/csvbulkexport.class.inc.php b/core/csvbulkexport.class.inc.php index 50a92f8f0..dd445217e 100644 --- a/core/csvbulkexport.class.inc.php +++ b/core/csvbulkexport.class.inc.php @@ -125,8 +125,8 @@ class CSVBulkExport extends TabularBulkExport $sRawSeparator = utils::ReadParam('separator', ',', true, 'raw_data'); $sCustomDateTimeFormat = utils::ReadParam('', ',', true, 'raw_data'); $aSep = array( - ';' => Dict::S('UI:CSVImport:SeparatorSemicolon+'), - ',' => Dict::S('UI:CSVImport:SeparatorComma+'), + ';' => Dict::S('UI:CSVImport:SeparatorSemicolon+'), + ',' => Dict::S('UI:CSVImport:SeparatorComma+'), 'tab' => Dict::S('UI:CSVImport:SeparatorTab+'), ); $sOtherSeparator = ''; @@ -134,10 +134,10 @@ class CSVBulkExport extends TabularBulkExport $sOtherSeparator = $sRawSeparator; $sRawSeparator = 'other'; } - $aSep['other'] = Dict::S('UI:CSVImport:SeparatorOther').' '; + $aSep['other'] = Dict::S('UI:CSVImport:SeparatorOther').' '; foreach ($aSep as $sVal => $sLabel) { - $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "separator", htmlentities($sVal, ENT_QUOTES, 'UTF-8'), $sLabel, "radio"); + $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "separator", utils::EscapeHtml($sVal), $sLabel, "radio"); $oRadio->GetInput()->SetIsChecked(($sVal == $sRawSeparator)); $oRadio->SetBeforeInput(false); $oRadio->GetInput()->AddCSSClass('ibo-input--label-right'); @@ -152,7 +152,7 @@ class CSVBulkExport extends TabularBulkExport $sRawQualifier = utils::ReadParam('text-qualifier', '"', true, 'raw_data'); $aQualifiers = array( - '"' => Dict::S('UI:CSVImport:QualifierDoubleQuote+'), + '"' => Dict::S('UI:CSVImport:QualifierDoubleQuote+'), '\'' => Dict::S('UI:CSVImport:QualifierSimpleQuote+'), ); $sOtherQualifier = ''; @@ -160,10 +160,10 @@ class CSVBulkExport extends TabularBulkExport $sOtherQualifier = $sRawQualifier; $sRawQualifier = 'other'; } - $aQualifiers['other'] = Dict::S('UI:CSVImport:QualifierOther').' '; + $aQualifiers['other'] = Dict::S('UI:CSVImport:QualifierOther').' '; foreach ($aQualifiers as $sVal => $sLabel) { - $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "text-qualifier", htmlentities($sVal, ENT_QUOTES, 'UTF-8'), $sLabel, "radio"); + $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "text-qualifier", utils::EscapeHtml($sVal), $sLabel, "radio"); $oRadio->GetInput()->SetIsChecked(($sVal == $sRawSeparator)); $oRadio->SetBeforeInput(false); $oRadio->GetInput()->AddCSSClass('ibo-input--label-right'); @@ -209,8 +209,8 @@ class CSVBulkExport extends TabularBulkExport $sDateTimeFormat = utils::ReadParam('date_format', (string)AttributeDateTime::GetFormat(), true, 'raw_data'); - $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); - $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); + $sDefaultFormat = utils::EscapeHtml((string)AttributeDateTime::GetFormat()); + $sExample = utils::EscapeHtml(date((string)AttributeDateTime::GetFormat())); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "csv_date_format_radio", "default", "csv_date_time_format_default", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->SetBeforeInput(false); @@ -218,7 +218,7 @@ class CSVBulkExport extends TabularBulkExport $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('
')); - $sFormatInput = ''; + $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "csv_date_format_radio", "custom", "csv_date_time_format_custom", "radio"); $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); @@ -246,17 +246,18 @@ EOF } protected function GetSampleData($oObj, $sAttCode) - { - if ($sAttCode != 'id') - { + { + if ($sAttCode != 'id') { $oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $sAttCode); if ($oAttDef instanceof AttributeDateTime) // AttributeDate is derived from AttributeDateTime { $sClass = (get_class($oAttDef) == 'AttributeDateTime') ? 'user-formatted-date-time' : 'user-formatted-date'; - return '
'.htmlentities($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj), ENT_QUOTES, 'UTF-8').'
'; + + return '
'.utils::EscapeHtml($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj)).'
'; } } - return '
'.htmlentities($this->GetValue($oObj, $sAttCode), ENT_QUOTES, 'UTF-8').'
'; + + return '
'.utils::EscapeHtml($this->GetValue($oObj, $sAttCode)).'
'; } protected function GetValue($oObj, $sAttCode) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 48b27e305..2cc199b25 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -1088,9 +1088,10 @@ abstract class DBObject implements iDisplay } else { - $sHtmlLabel = htmlentities($this->Get($sAttCode.'_friendlyname'), ENT_QUOTES, 'UTF-8'); + $sHtmlLabel = utils::EscapeHtml($this->Get($sAttCode.'_friendlyname')); $bArchived = $this->IsArchived($sAttCode); $bObsolete = $this->IsObsolete($sAttCode); + return $this->MakeHyperLink($sTargetClass, $iTargetKey, $sHtmlLabel, null, true, $bArchived, $bObsolete); } } @@ -1588,7 +1589,7 @@ abstract class DBObject implements iDisplay */ public function GetName($sType = FriendlyNameType::SHORT) { - return htmlentities($this->GetRawName($sType), ENT_QUOTES, 'UTF-8'); + return utils::EscapeHtml($this->GetRawName($sType)); } /** diff --git a/core/designdocument.class.inc.php b/core/designdocument.class.inc.php index 29c1fe743..97c65c5d3 100644 --- a/core/designdocument.class.inc.php +++ b/core/designdocument.class.inc.php @@ -93,13 +93,12 @@ class DesignDocument extends DOMDocument public function Dump($bReturnRes = false) { $sXml = $this->saveXML(); - if ($bReturnRes) - { + if ($bReturnRes) { return $sXml; } echo "
\n";
-		echo htmlentities($sXml);
+		echo utils::EscapeHtml($sXml);
 		echo "
\n"; return ''; @@ -192,13 +191,13 @@ class DesignElement extends \DOMElement $oDoc->appendChild($oClone); $sXml = $oDoc->saveXML($oClone); - if ($bReturnRes) - { + if ($bReturnRes) { return $sXml; } echo "
\n";
-		echo htmlentities($sXml);
+		echo utils::EscapeHtml($sXml);
 		echo "
\n"; + return ''; } /** diff --git a/core/displayablegraph.class.inc.php b/core/displayablegraph.class.inc.php index 330e585e8..0602e4e8d 100644 --- a/core/displayablegraph.class.inc.php +++ b/core/displayablegraph.class.inc.php @@ -459,11 +459,10 @@ class DisplayableNode extends GraphNode { $aContext = $aContextDefs[$key]; $aRootCauses = array(); - foreach($aObjects as $oRootCause) - { + foreach ($aObjects as $oRootCause) { $aRootCauses[] = $oRootCause->GetHyperlink(); } - $sHtml .= '

 '.implode(', ', $aRootCauses).'

'; + $sHtml .= '

 '.implode(', ', $aRootCauses).'

'; } $sHtml .= '
'; } @@ -1335,18 +1334,17 @@ class DisplayableGraph extends SimpleGraph } $oPdf->Rect($xMin, $yMin, $fMaxWidth + $fIconSize + 3*$fPadding, $yMax - $yMin, 'D'); - if ($sComments != '') - { + if ($sComments != '') { // Draw the comment text (surrounded by a rectangle) - $xPos = $xMin + $fMaxWidth + $fIconSize + 4*$fPadding; - $w = $xMax - $xPos - 2*$fPadding; + $xPos = $xMin + $fMaxWidth + $fIconSize + 4 * $fPadding; + $w = $xMax - $xPos - 2 * $fPadding; $iNbLines = 1; - $sText = '

'.str_replace("\n", '
', htmlentities($sComments, ENT_QUOTES, 'UTF-8'), $iNbLines).'

'; + $sText = '

'.str_replace("\n", '
', utils::EscapeHtml($sComments), $iNbLines).'

'; $fLineHeight = $oPdf->getStringHeight($w, $sText); - $h = (1+$iNbLines) * $fLineHeight; - $yPos = $yMax - 2*$fPadding - $h; + $h = (1 + $iNbLines) * $fLineHeight; + $yPos = $yMax - 2 * $fPadding - $h; $oPdf->writeHTMLCell($w, $h, $xPos + $fPadding, $yPos + $fPadding, $sText, 0 /* border */, 1 /* ln */); - $oPdf->Rect($xPos, $yPos, $w + 2*$fPadding, $h + 2*$fPadding, 'D'); + $oPdf->Rect($xPos, $yPos, $w + 2 * $fPadding, $h + 2 * $fPadding, 'D'); $yMax = $yPos - $fPadding; } diff --git a/core/excelbulkexport.class.inc.php b/core/excelbulkexport.class.inc.php index caecf7111..78c81ed5d 100644 --- a/core/excelbulkexport.class.inc.php +++ b/core/excelbulkexport.class.inc.php @@ -100,8 +100,8 @@ class ExcelBulkExport extends TabularBulkExport $sDateTimeFormat = utils::ReadParam('date_format', (string)AttributeDateTime::GetFormat(), true, 'raw_data'); - $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); - $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); + $sDefaultFormat = utils::EscapeHtml((string)AttributeDateTime::GetFormat()); + $sExample = utils::EscapeHtml(date((string)AttributeDateTime::GetFormat())); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "excel_date_format_radio", "default", "excel_date_time_format_default", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->SetBeforeInput(false); @@ -109,7 +109,7 @@ class ExcelBulkExport extends TabularBulkExport $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('
')); - $sFormatInput = ''; + $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "excel_date_format_radio", "custom", "excel_date_time_format_custom", "radio"); $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); @@ -156,16 +156,17 @@ EOF protected function GetSampleData($oObj, $sAttCode) { - if ($sAttCode != 'id') - { + if ($sAttCode != 'id') { $oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $sAttCode); if ($oAttDef instanceof AttributeDateTime) // AttributeDate is derived from AttributeDateTime { $sClass = (get_class($oAttDef) == 'AttributeDateTime') ? 'user-formatted-date-time' : 'user-formatted-date'; - return '
'.htmlentities($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj), ENT_QUOTES, 'UTF-8').'
'; + + return '
'.utils::EscapeHtml($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj)).'
'; } } - return '
'.htmlentities($this->GetValue($oObj, $sAttCode), ENT_QUOTES, 'UTF-8').'
'; + + return '
'.utils::EscapeHtml($this->GetValue($oObj, $sAttCode)).'
'; } protected function GetValue($oObj, $sAttCode) diff --git a/core/htmlbulkexport.class.inc.php b/core/htmlbulkexport.class.inc.php index 0b5a62bf2..685734e86 100644 --- a/core/htmlbulkexport.class.inc.php +++ b/core/htmlbulkexport.class.inc.php @@ -62,7 +62,8 @@ class HTMLBulkExport extends TabularBulkExport if ($oAttDef instanceof AttributeDateTime) // AttributeDate is derived from AttributeDateTime { $sClass = (get_class($oAttDef) == 'AttributeDateTime') ? 'user-formatted-date-time' : 'user-formatted-date'; - return '
'.htmlentities($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj), ENT_QUOTES, 'UTF-8').'
'; + + return '
'.utils::EscapeHtml($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj)).'
'; } } return $this->GetValue($oObj, $sAttCode); diff --git a/core/inlineimage.class.inc.php b/core/inlineimage.class.inc.php index ec71d82a0..66aa6d70d 100644 --- a/core/inlineimage.class.inc.php +++ b/core/inlineimage.class.inc.php @@ -295,13 +295,12 @@ class InlineImage extends DBObject { $sImgTag = $aImgInfo[0][0]; $sSecret = ''; - if (preg_match('/data-img-secret="([0-9a-f]+)"/', $sImgTag, $aSecretMatches)) - { + if (preg_match('/data-img-secret="([0-9a-f]+)"/', $sImgTag, $aSecretMatches)) { $sSecret = '&s='.$aSecretMatches[1]; } $sAttId = $aImgInfo[2][0]; - - $sNewImgTag = preg_replace('/src="[^"]+"/', 'src="'.htmlentities($sUrl.$sAttId.$sSecret, ENT_QUOTES, 'UTF-8').'"', $sImgTag); // preserve other attributes, must convert & to & to be idempotent with CKEditor + + $sNewImgTag = preg_replace('/src="[^"]+"/', 'src="'.utils::EscapeHtml($sUrl.$sAttId.$sSecret).'"', $sImgTag); // preserve other attributes, must convert & to & to be idempotent with CKEditor $aNeedles[] = $sImgTag; $aReplacements[] = $sNewImgTag; } @@ -536,8 +535,8 @@ JS $iObjKey = $oObject->GetKey(); $sAbsoluteUrlAppRoot = utils::GetAbsoluteUrlAppRoot(); - $sToggleFullScreen = htmlentities(Dict::S('UI:ToggleFullScreen'), ENT_QUOTES, 'UTF-8'); - + $sToggleFullScreen = utils::EscapeHtml(Dict::S('UI:ToggleFullScreen')); + return <<\n"; - echo " \n"; + echo " \n"; echo " \n"; echo "\n"; } @@ -5263,24 +5259,21 @@ abstract class MetaModel $sRes = ''; $sRes .= "// Dictionnay conventions\n"; - $sRes .= htmlentities("// Class:\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:+\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Attribute:\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Attribute:+\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Attribute:/Value:\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Attribute:/Value:+\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Stimulus:\n", ENT_QUOTES, 'UTF-8'); - $sRes .= htmlentities("// Class:/Stimulus:+\n", ENT_QUOTES, 'UTF-8'); + $sRes .= utils::EscapeHtml("// Class:\n"); + $sRes .= utils::EscapeHtml("// Class:+\n"); + $sRes .= utils::EscapeHtml("// Class:/Attribute:\n"); + $sRes .= utils::EscapeHtml("// Class:/Attribute:+\n"); + $sRes .= utils::EscapeHtml("// Class:/Attribute:/Value:\n"); + $sRes .= utils::EscapeHtml("// Class:/Attribute:/Value:+\n"); + $sRes .= utils::EscapeHtml("// Class:/Stimulus:\n"); + $sRes .= utils::EscapeHtml("// Class:/Stimulus:+\n"); $sRes .= "\n"; // Note: I did not use EnumCategories(), because a given class maybe found in several categories // Need to invent the "module", to characterize the origins of a class - if (strlen($sModules) == 0) - { + if (strlen($sModules) == 0) { $aModules = array('bizmodel', 'core/cmdb', 'gui', 'application', 'addon/userrights'); - } - else - { + } else { $aModules = explode(', ', $sModules); } @@ -5288,17 +5281,14 @@ abstract class MetaModel $sRes .= "// Note: The classes have been grouped by categories: ".implode(', ', $aModules)."\n"; $sRes .= "//////////////////////////////////////////////////////////////////////\n"; - foreach($aModules as $sCategory) - { + foreach ($aModules as $sCategory) { $sRes .= "//////////////////////////////////////////////////////////////////////\n"; $sRes .= "// Classes in '$sCategory'\n"; $sRes .= "//////////////////////////////////////////////////////////////////////\n"; $sRes .= "//\n"; $sRes .= "\n"; - foreach(self::GetClasses($sCategory) as $sClass) - { - if (!self::HasTable($sClass)) - { + foreach (self::GetClasses($sCategory) as $sClass) { + if (!self::HasTable($sClass)) { continue; } @@ -7022,30 +7012,26 @@ abstract class MetaModel */ public static function GetHyperLink($sTargetClass, $iKey) { - if ($iKey < 0) - { + if ($iKey < 0) { return "$sTargetClass: $iKey (invalid value)"; } $oObj = self::GetObject($sTargetClass, $iKey, false); - if (is_null($oObj)) - { + if (is_null($oObj)) { // Whatever we are looking for, the root class is the key to search for $sRootClass = self::GetRootClass($sTargetClass); $oSearch = DBObjectSearch::FromOQL('SELECT CMDBChangeOpDelete WHERE objclass = :objclass AND objkey = :objkey', array('objclass' => $sRootClass, 'objkey' => $iKey)); $oSet = new DBObjectSet($oSearch); $oRecord = $oSet->Fetch(); // An empty fname is obtained with iTop < 2.0 - if (is_null($oRecord) || (strlen(trim($oRecord->Get('fname'))) == 0)) - { + if (is_null($oRecord) || (strlen(trim($oRecord->Get('fname'))) == 0)) { $sName = Dict::Format('Core:UnknownObjectLabel', $sTargetClass, $iKey); $sTitle = Dict::S('Core:UnknownObjectTip'); - } - else - { + } else { $sName = $oRecord->Get('fname'); $sTitle = Dict::Format('Core:DeletedObjectTip', $oRecord->Get('date'), $oRecord->Get('userinfo')); } - return ''.htmlentities($sName, ENT_QUOTES, 'UTF-8').''; + + return ''.utils::EscapeHtml($sName).''; } return $oObj->GetHyperLink(); } diff --git a/core/oql/oqlexception.class.inc.php b/core/oql/oqlexception.class.inc.php index f336bc4e3..81e771b27 100644 --- a/core/oql/oqlexception.class.inc.php +++ b/core/oql/oqlexception.class.inc.php @@ -58,22 +58,19 @@ class OQLException extends CoreException public function getHtmlDesc($sHighlightHtmlBegin = '', $sHighlightHtmlEnd = '') { - $sRet = htmlentities($this->m_MyIssue.", found '".$this->m_sUnexpected."' in: ", ENT_QUOTES, 'UTF-8'); - $sRet .= htmlentities(substr($this->m_sInput, 0, $this->m_iCol), ENT_QUOTES, 'UTF-8'); - $sRet .= $sHighlightHtmlBegin.htmlentities(substr($this->m_sInput, $this->m_iCol, strlen($this->m_sUnexpected)), ENT_QUOTES, 'UTF-8').$sHighlightHtmlEnd; - $sRet .= htmlentities(substr($this->m_sInput, $this->m_iCol + strlen($this->m_sUnexpected)), ENT_QUOTES, 'UTF-8'); + $sRet = utils::EscapeHtml($this->m_MyIssue.", found '".$this->m_sUnexpected."' in: "); + $sRet .= utils::EscapeHtml(substr($this->m_sInput, 0, $this->m_iCol)); + $sRet .= $sHighlightHtmlBegin.utils::EscapeHtml(substr($this->m_sInput, $this->m_iCol, strlen($this->m_sUnexpected))).$sHighlightHtmlEnd; + $sRet .= utils::EscapeHtml(substr($this->m_sInput, $this->m_iCol + strlen($this->m_sUnexpected))); - if (!is_null($this->m_aExpecting) && (count($this->m_aExpecting) > 0)) - { - if (count($this->m_aExpecting) < 30) - { + if (!is_null($this->m_aExpecting) && (count($this->m_aExpecting) > 0)) { + if (count($this->m_aExpecting) < 30) { $sExpectations = '{'.implode(', ', $this->m_aExpecting).'}'; - $sRet .= ", expecting ".htmlentities($sExpectations, ENT_QUOTES, 'UTF-8'); - } + $sRet .= ", expecting ".utils::EscapeHtml($sExpectations); + } $sSuggest = self::FindClosestString($this->m_sUnexpected, $this->m_aExpecting); - if (strlen($sSuggest) > 0) - { - $sRet .= ", I would suggest to use '$sHighlightHtmlBegin".htmlentities($sSuggest, ENT_QUOTES, 'UTF-8')."$sHighlightHtmlEnd'"; + if (strlen($sSuggest) > 0) { + $sRet .= ", I would suggest to use '$sHighlightHtmlBegin".utils::EscapeHtml($sSuggest)."$sHighlightHtmlEnd'"; } } diff --git a/core/ormcaselog.class.inc.php b/core/ormcaselog.class.inc.php index 950ff0627..03a4a3612 100644 --- a/core/ormcaselog.class.inc.php +++ b/core/ormcaselog.class.inc.php @@ -252,7 +252,7 @@ class ormCaseLog { if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == static::ENUM_FORMAT_TEXT)) { $sCSSClass = 'caselog_entry'; - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
", utils::EscapeHtml($sTextEntry)); } else { @@ -292,19 +292,15 @@ class ormCaseLog { } // Process the case of an eventual remainder (quick migration of AttributeText fields) - if ($iPos < (strlen($this->m_sLog) - 1)) - { + if ($iPos < (strlen($this->m_sLog) - 1)) { $sTextEntry = substr($this->m_sLog, $iPos); - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
", utils::EscapeHtml($sTextEntry)); - if (count($this->m_aIndex) == 0) - { + if (count($this->m_aIndex) == 0) { $sHtml .= '
'; $sHtml .= $sTextEntry; $sHtml .= '
'; - } - else - { + } else { $sHtml .= '
'; $sHtml .= Dict::S('UI:CaseLog:InitialValue'); $sHtml .= '
'; @@ -327,24 +323,18 @@ class ormCaseLog { $sHtml = '
    '; $iPos = 0; $aIndex = $this->m_aIndex; - for($index=count($aIndex)-1 ; $index >= 0 ; $index--) - { + for($index=count($aIndex)-1 ; $index >= 0 ; $index--) { $iPos += $aIndex[$index]['separator_length']; $sTextEntry = substr($this->m_sLog, $iPos, $aIndex[$index]['text_length']); $sCSSClass = 'case_log_simple_html_entry_html'; - if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == static::ENUM_FORMAT_TEXT)) - { + if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == static::ENUM_FORMAT_TEXT)) { $sCSSClass = 'case_log_simple_html_entry'; - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); - if (!is_null($aTransfoHandler)) - { + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", utils::EscapeHtml($sTextEntry)); + if (!is_null($aTransfoHandler)) { $sTextEntry = call_user_func($aTransfoHandler, $sTextEntry); } - } - else - { - if (!is_null($aTransfoHandler)) - { + } else { + if (!is_null($aTransfoHandler)) { $sTextEntry = call_user_func($aTransfoHandler, $sTextEntry, true /* wiki "links" only */); } $sTextEntry = InlineImage::FixUrls($sTextEntry); @@ -383,19 +373,15 @@ class ormCaseLog { } // Process the case of an eventual remainder (quick migration of AttributeText fields) - if ($iPos < (strlen($this->m_sLog) - 1)) - { + if ($iPos < (strlen($this->m_sLog) - 1)) { $sTextEntry = substr($this->m_sLog, $iPos); - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", utils::EscapeHtml($sTextEntry)); - if (count($this->m_aIndex) == 0) - { + if (count($this->m_aIndex) == 0) { $sHtml .= '
  • '; $sHtml .= $sTextEntry; $sHtml .= '
  • '; - } - else - { + } else { $sHtml .= '
  • '; $sHtml .= Dict::S('UI:CaseLog:InitialValue'); $sHtml .= '
    '; @@ -437,11 +423,9 @@ class ormCaseLog { } $iPos += $aIndex[$index]['separator_length']; $sTextEntry = substr($this->m_sLog, $iPos, $aIndex[$index]['text_length']); - if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == static::ENUM_FORMAT_TEXT)) - { - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); - if (!is_null($aTransfoHandler)) - { + if (!array_key_exists('format', $aIndex[$index]) || ($aIndex[$index]['format'] == static::ENUM_FORMAT_TEXT)) { + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", utils::EscapeHtml($sTextEntry)); + if (!is_null($aTransfoHandler)) { $sTextEntry = call_user_func($aTransfoHandler, $sTextEntry); } } @@ -483,19 +467,16 @@ class ormCaseLog { $oBlock->AddSubBlock($oCollapsibleBlock); } // Process the case of an eventual remainder (quick migration of AttributeText fields) - if ($iPos < (strlen($this->m_sLog) - 1)) - { + if ($iPos < (strlen($this->m_sLog) - 1)) { // In this case the format is always "text" $sTextEntry = substr($this->m_sLog, $iPos); - $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", htmlentities($sTextEntry, ENT_QUOTES, 'UTF-8')); - if (!is_null($aTransfoHandler)) - { + $sTextEntry = str_replace(array("\r\n", "\n", "\r"), "
    ", utils::EscapeHtml($sTextEntry)); + if (!is_null($aTransfoHandler)) { $sTextEntry = call_user_func($aTransfoHandler, $sTextEntry); } - if (count($this->m_aIndex) == 0) - { - $oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard( ''); + if (count($this->m_aIndex) == 0) { + $oCollapsibleBlock = CollapsibleSectionUIBlockFactory::MakeStandard(''); $oCollapsibleBlock->AddSubBlock(new Html($sTextEntry)); $oCollapsibleBlock->SetOpenedByDefault(true); $oBlock->AddSubBlock($oCollapsibleBlock); diff --git a/core/ormdocument.class.inc.php b/core/ormdocument.class.inc.php index 1af6b5c67..badd01904 100644 --- a/core/ormdocument.class.inc.php +++ b/core/ormdocument.class.inc.php @@ -109,17 +109,14 @@ class ormDocument public function GetAsHTML() { $sResult = ''; - if ($this->IsEmpty()) - { + if ($this->IsEmpty()) { // If the filename is not empty, display it, this is used // by the creation wizard while the file has not yet been uploaded - $sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8'); - } - else - { + $sResult = utils::EscapeHtml($this->GetFileName()); + } else { $data = $this->GetData(); $sSize = utils::BytesToFriendlyFormat(strlen($data)); - $sResult = htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8').' ('.$sSize.')
    '; + $sResult = utils::EscapeHtml($this->GetFileName()).' ('.$sSize.')
    '; } return $sResult; } @@ -131,7 +128,8 @@ class ormDocument public function GetDisplayLink($sClass, $Id, $sAttCode) { $sUrl = $this->GetDisplayURL($sClass, $Id, $sAttCode); - return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; + + return "".utils::EscapeHtml($this->GetFileName())."\n"; } /** @@ -141,7 +139,8 @@ class ormDocument public function GetDownloadLink($sClass, $Id, $sAttCode) { $sUrl = $this->GetDownloadURL($sClass, $Id, $sAttCode); - return "".htmlentities($this->GetFileName(), ENT_QUOTES, 'UTF-8')."\n"; + + return "".utils::EscapeHtml($this->GetFileName())."\n"; } /** diff --git a/core/pdfbulkexport.class.inc.php b/core/pdfbulkexport.class.inc.php index ba25a61ed..df22d7141 100644 --- a/core/pdfbulkexport.class.inc.php +++ b/core/pdfbulkexport.class.inc.php @@ -62,7 +62,7 @@ class PDFBulkExport extends HTMLBulkExport $aPossibleFormat = ['A3', 'A4', 'Letter']; $sDefaultFormat = 'A4'; foreach ($aPossibleFormat as $sVal) { - $oSelectFormat->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, htmlentities(Dict::S('Core:BulkExport:PageSize-'.$sVal), ENT_QUOTES, 'UTF-8'), ($sVal == $sDefaultFormat))); + $oSelectFormat->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, utils::EscapeHtml(Dict::S('Core:BulkExport:PageSize-'.$sVal)), ($sVal == $sDefaultFormat))); } $oFieldSetFormat->AddSubBlock(new Html('
    ')); @@ -75,7 +75,7 @@ class PDFBulkExport extends HTMLBulkExport $aPossibleOrientation = ['P', 'L']; $sDefaultOrientation = 'L'; foreach ($aPossibleOrientation as $sVal) { - $oSelectOrientation->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, htmlentities(Dict::S('Core:BulkExport:PageOrientation-'.$sVal), ENT_QUOTES, 'UTF-8'), ($sVal == $sDefaultOrientation))); + $oSelectOrientation->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sVal, utils::EscapeHtml(Dict::S('Core:BulkExport:PageOrientation-'.$sVal)), ($sVal == $sDefaultOrientation))); } //date format @@ -84,8 +84,8 @@ class PDFBulkExport extends HTMLBulkExport $sDateTimeFormat = utils::ReadParam('date_format', (string)AttributeDateTime::GetFormat(), true, 'raw_data'); - $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); - $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); + $sDefaultFormat = utils::EscapeHtml((string)AttributeDateTime::GetFormat()); + $sExample = utils::EscapeHtml(date((string)AttributeDateTime::GetFormat())); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "pdf_date_format_radio", "default", "pdf_date_time_format_default", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->SetBeforeInput(false); @@ -93,7 +93,7 @@ class PDFBulkExport extends HTMLBulkExport $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('
    ')); - $sFormatInput = ''; + $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "pdf_date_format_radio", "custom", "pdf_date_time_format_custom", "radio"); $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); diff --git a/core/spreadsheetbulkexport.class.inc.php b/core/spreadsheetbulkexport.class.inc.php index 50629d400..6bd557dc8 100644 --- a/core/spreadsheetbulkexport.class.inc.php +++ b/core/spreadsheetbulkexport.class.inc.php @@ -73,8 +73,8 @@ class SpreadsheetBulkExport extends TabularBulkExport $sDateTimeFormat = utils::ReadParam('date_format', (string)AttributeDateTime::GetFormat(), true, 'raw_data'); - $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); - $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); + $sDefaultFormat = utils::EscapeHtml((string)AttributeDateTime::GetFormat()); + $sExample = utils::EscapeHtml(date((string)AttributeDateTime::GetFormat())); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "spreadsheet_date_format_radio", "default", "spreadsheet_date_time_format_default", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->GetInput()->AddCSSClass('ibo-input-checkbox'); @@ -82,7 +82,7 @@ class SpreadsheetBulkExport extends TabularBulkExport $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('
    ')); - $sFormatInput = ''; + $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sFormatInput), "spreadsheet_date_format_radio", "custom", "spreadsheet_date_time_format_custom", "radio"); $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); @@ -140,7 +140,8 @@ EOF if ($oAttDef instanceof AttributeDateTime) // AttributeDate is derived from AttributeDateTime { $sClass = (get_class($oAttDef) == 'AttributeDateTime') ? 'user-formatted-date-time' : 'user-formatted-date'; - return '
    '.htmlentities($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj), ENT_QUOTES, 'UTF-8').'
    '; + + return '
    '.utils::EscapeHtml($oAttDef->GetEditValue($oObj->Get($sAttCode), $oObj)).'
    '; } } return $this->GetValue($oObj, $sAttCode); @@ -158,19 +159,13 @@ EOF default: $value = $oObj->Get($sAttCode); $oAttDef = MetaModel::GetAttributeDef(get_class($oObj), $sAttCode); - if ($value instanceof ormCaseLog) - { - $sRet = str_replace("\n", "
    ", htmlentities($value->__toString(), ENT_QUOTES, 'UTF-8')); - } - elseif ($value instanceof ormStopWatch) - { + if ($value instanceof ormCaseLog) { + $sRet = str_replace("\n", "
    ", utils::EscapeHtml($value->__toString())); + } elseif ($value instanceof ormStopWatch) { $sRet = $value->GetTimeSpent(); - } - elseif ($value instanceof ormDocument) - { + } elseif ($value instanceof ormDocument) { $sRet = ''; - } - elseif ($oAttDef instanceof AttributeText) + } elseif ($oAttDef instanceof AttributeText) { if ($bFormattedText) { @@ -191,15 +186,11 @@ EOF // Stick to the weird implementation made in GetNextChunk $sRet = utils::TextToHtml($oObj->GetEditValue($sAttCode)); } - else - { - if ($this->bLocalizeOutput) - { - $sRet = htmlentities($oObj->GetEditValue(), ENT_QUOTES, 'UTF-8'); - } - else - { - $sRet = htmlentities((string)$value, ENT_QUOTES, 'UTF-8'); + else { + if ($this->bLocalizeOutput) { + $sRet = utils::EscapeHtml($oObj->GetEditValue()); + } else { + $sRet = utils::EscapeHtml((string)$value); } } } @@ -314,22 +305,16 @@ EOF $sData .= "$sDate"; $sData .= "$sTime"; } - else if (get_class($oFinalAttDef) == 'AttributeDate') - { + else if (get_class($oFinalAttDef) == 'AttributeDate') { $sDate = $oDateFormat->Format($oObj->Get($sAttCode)); $sData .= "$sDate"; - } - else if($oAttDef instanceof AttributeCaseLog) - { + } else if ($oAttDef instanceof AttributeCaseLog) { $rawValue = $oObj->Get($sAttCode); - $sField = str_replace("\n", "
    ", htmlentities($rawValue->__toString(), ENT_QUOTES, 'UTF-8')); + $sField = str_replace("\n", "
    ", utils::EscapeHtml($rawValue->__toString())); // Trick for Excel: treat the content as text even if it begins with an equal sign $sData .= "$sField"; - } - elseif ($oAttDef instanceof AttributeText) - { - if ($bFormattedText) - { + } elseif ($oAttDef instanceof AttributeText) { + if ($bFormattedText) { // Replace paragraphs (...

    , etc) by line breaks (
    ) since Excel (pre-2016) splits the cells when there is a paragraph $sField = static::HtmlToSpreadsheet($oObj->GetAsHTML($sAttCode)); } @@ -356,16 +341,12 @@ EOF $sField = utils::HtmlEntities($oObj->GetAsCSV($sAttCode, $this->bLocalizeOutput, '')); $sData .= "$sField"; } - else - { + else { $rawValue = $oObj->Get($sAttCode); - if ($this->bLocalizeOutput) - { - $sField = htmlentities($oFinalAttDef->GetEditValue($rawValue), ENT_QUOTES, 'UTF-8'); - } - else - { - $sField = htmlentities($rawValue, ENT_QUOTES, 'UTF-8'); + if ($this->bLocalizeOutput) { + $sField = utils::EscapeHtml($oFinalAttDef->GetEditValue($rawValue)); + } else { + $sField = utils::EscapeHtml($rawValue); } $sData .= "$sField"; } diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 4567bc8ac..adfa4cb18 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -527,7 +527,7 @@ abstract class User extends cmdbAbstractObject { if (UserRights::IsStimulusAllowed($sClass, $sStimulusCode, null, $this)) { - $aStimuli[] = ''.htmlentities($oStimulus->GetLabel(), ENT_QUOTES, 'UTF-8').''; + $aStimuli[] = ''.utils::EscapeHtml($oStimulus->GetLabel()).''; } } $sStimuli = implode(', ', $aStimuli); diff --git a/datamodels/2.x/itop-attachments/ajax.itop-attachment.php b/datamodels/2.x/itop-attachments/ajax.itop-attachment.php index f5f45997c..cdf5d1aef 100644 --- a/datamodels/2.x/itop-attachments/ajax.itop-attachment.php +++ b/datamodels/2.x/itop-attachments/ajax.itop-attachment.php @@ -104,7 +104,7 @@ try $oAttachment->Set('contents', $oDoc); $iAttId = $oAttachment->DBInsert(); - $aResult['msg'] = htmlentities($oDoc->GetFileName(), ENT_QUOTES, 'UTF-8'); + $aResult['msg'] = utils::EscapeHtml($oDoc->GetFileName()); $aResult['icon'] = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($oDoc->GetFileName()); $aResult['att_id'] = $iAttId; $aResult['preview'] = $oDoc->IsPreviewAvailable() ? 'true' : 'false'; @@ -138,9 +138,8 @@ try $oPage->output(); } -catch (Exception $e) -{ +catch (Exception $e) { // note: transform to cope with XSS attacks - echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8'); + echo utils::EscapeHtml($e->GetMessage()); IssueLog::Error($e->getMessage()); } diff --git a/datamodels/2.x/itop-attachments/main.itop-attachments.php b/datamodels/2.x/itop-attachments/main.itop-attachments.php index 24ad38a6e..dad027bf6 100644 --- a/datamodels/2.x/itop-attachments/main.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/main.itop-attachments.php @@ -679,13 +679,12 @@ class CMDBChangeOpAttachmentAdded extends CMDBChangeOp // Temporary, until we change the options of GetDescription() -needs a more global revision $sTargetObjectClass = 'Attachment'; $iTargetObjectKey = $this->Get('attachment_id'); - $sFilename = htmlentities($this->Get('filename'), ENT_QUOTES, 'UTF-8'); + $sFilename = utils::EscapeHtml($this->Get('filename')); $oTargetSearch = new DBObjectSearch($sTargetObjectClass); $oTargetSearch->AddCondition('id', $iTargetObjectKey, '='); $oMonoObjectSet = new DBObjectSet($oTargetSearch); - if ($oMonoObjectSet->Count() > 0) - { + if ($oMonoObjectSet->Count() > 0) { $oAttachment = $oMonoObjectSet->Fetch(); $oDoc = $oAttachment->Get('contents'); $sPreview = $oDoc->IsPreviewAvailable() ? 'data-preview="true"' : ''; @@ -739,7 +738,7 @@ class CMDBChangeOpAttachmentRemoved extends CMDBChangeOp { // Temporary, until we change the options of GetDescription() -needs a more global revision $sResult = Dict::Format('Attachments:History_File_Removed', - ''.htmlentities($this->Get('filename'), ENT_QUOTES, 'UTF-8').''); + ''.utils::EscapeHtml($this->Get('filename')).''); return $sResult; } diff --git a/datamodels/2.x/itop-config/config.php b/datamodels/2.x/itop-config/config.php index eca3dba63..3db15541b 100644 --- a/datamodels/2.x/itop-config/config.php +++ b/datamodels/2.x/itop-config/config.php @@ -170,7 +170,8 @@ try { $iEditorTopMargin += 5*$iWarnings; $sOriginalConfig = str_replace("\r\n", "\n", file_get_contents($sConfigFile)); - } catch (Exception $e) { + } + catch (Exception $e) { $oAlert = AlertUIBlockFactory::MakeForDanger('', $e->getMessage()); $iEditorTopMargin += 5; $oP->AddUiBlock($oAlert); @@ -180,8 +181,8 @@ try { } - $sConfigEscaped = htmlentities($sConfig, ENT_QUOTES, 'UTF-8'); - $sOriginalConfigEscaped = htmlentities($sOriginalConfig, ENT_QUOTES, 'UTF-8'); + $sConfigEscaped = utils::EscapeHtml($sConfig); + $sOriginalConfigEscaped = utils::EscapeHtml($sOriginalConfig); $oP->AddUiBlock(new Html('

    '.Dict::S('config-edit-intro').'

    ')); $oForm = new Form(); diff --git a/datamodels/2.x/itop-hub-connector/land.php b/datamodels/2.x/itop-hub-connector/land.php index ed4a32264..8129422fd 100644 --- a/datamodels/2.x/itop-hub-connector/land.php +++ b/datamodels/2.x/itop-hub-connector/land.php @@ -36,11 +36,11 @@ function DisplayStatus(WebPage $oPage) $sCode = $oExtension->sCode; $sDir = basename($oExtension->sSourceDir); $oPage->add(' '); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    '); $oPage->add('

    '); if ($oExtension->sDescription != '') { - $oPage->add(htmlentities($oExtension->sDescription, ENT_QUOTES, 'UTF-8').'
    '); + $oPage->add(utils::EscapeHtml($oExtension->sDescription).'
    '); } $oPage->add('

    '); $oPage->add('
    '); @@ -161,11 +161,11 @@ function DoInstall(WebPage $oPage) $oPage->add('
    '); $oPage->add(' '); $sTitle = Dict::Format('iTopHub:InstallationEffect:MissingDependencies_Details', implode(', ', $oExtension->aMissingDependencies)); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    '); $oPage->add('

    '); if ($oExtension->sDescription != '') { - $oPage->add(htmlentities($oExtension->sDescription, ENT_QUOTES, 'UTF-8').'
    '); + $oPage->add(utils::EscapeHtml($oExtension->sDescription).'
    '); } $oPage->add('

    '); $oPage->add('
    '); @@ -189,11 +189,11 @@ function DoInstall(WebPage $oPage) $sCode = $oExtension->sCode; $sDir = basename($oExtension->sSourceDir); $oPage->add(' '); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    '); $oPage->add('

    '); if ($oExtension->sDescription != '') { - $oPage->add(htmlentities($oExtension->sDescription, ENT_QUOTES, 'UTF-8').'
    '); + $oPage->add(utils::EscapeHtml($oExtension->sDescription).'
    '); } $oPage->add('

    '); $oPage->add('
    '); diff --git a/datamodels/2.x/itop-hub-connector/launch.php b/datamodels/2.x/itop-hub-connector/launch.php index e7fb355fe..629a7f0dd 100644 --- a/datamodels/2.x/itop-hub-connector/launch.php +++ b/datamodels/2.x/itop-hub-connector/launch.php @@ -282,7 +282,7 @@ try { $oPage = new NiceWebPage(''); $aDataToPost = MakeDataToPost($sTargetRoute); $oPage->add('
    '); - $oPage->add(''); + $oPage->add(''); $oPage->add_ready_script('$("#hub_launch_form").submit();'); break; @@ -333,7 +333,7 @@ HTML ); $sFormTarget = appUserPreferences::GetPref('itophub_open_in_new_window', 1) ? 'target="_blank"' : ''; $oPage->add(''); - $oPage->add(''); + $oPage->add(''); // $sNewWindowChecked = appUserPreferences::GetPref('itophub_open_in_new_window', 1) == 1 ? 'checked' : ''; // $oPage->add('


    '); diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php index 0acdfd0be..dca04b01e 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php @@ -1235,12 +1235,12 @@ class ObjectController extends BrickController $oAttachment->Set('contents', $oDocument); $iAttId = $oAttachment->DBInsert(); - $aData['msg'] = htmlentities($oDocument->GetFileName(), ENT_QUOTES, 'UTF-8'); + $aData['msg'] = utils::EscapeHtml($oDocument->GetFileName()); $aData['icon'] = utils::GetAbsoluteUrlAppRoot().'env-'.utils::GetCurrentEnvironment().'/itop-attachments/icons/icons8-image-file.svg'; // Checking if the instance has attachments if (class_exists('AttachmentPlugIn')) { - $aData['icon'] = utils::GetAbsoluteUrlAppRoot() . AttachmentPlugIn::GetFileIcon($oDocument->GetFileName()); + $aData['icon'] = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($oDocument->GetFileName()); } $aData['att_id'] = $iAttId; diff --git a/datamodels/2.x/itop-portal-base/portal/src/Helper/ApplicationHelper.php b/datamodels/2.x/itop-portal-base/portal/src/Helper/ApplicationHelper.php index 605af8efa..f2c07bfcd 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Helper/ApplicationHelper.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Helper/ApplicationHelper.php @@ -324,10 +324,9 @@ class ApplicationHelper if (substr($sFieldsetName, 0, 1) !== '_') { $sFieldsetHTML = "\t\t

    \n"; - $sFieldsetHTML .= "\t\t\t".htmlentities(Dict::S($sFieldsetName), ENT_QUOTES, 'UTF-8')."\n"; + $sFieldsetHTML .= "\t\t\t".utils::EscapeHtml(Dict::S($sFieldsetName))."\n"; - foreach ($aAttCodes as $sAttCode) - { + foreach ($aAttCodes as $sAttCode) { $sFieldsetHTML .= "\t\t\t
    \n"; } diff --git a/pages/UI.php b/pages/UI.php index c7db22ca0..d479ea8bc 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -632,17 +632,17 @@ try $oP->SetBreadCrumbEntry($sPageId, $sLabel, $sDescription, '', 'fas fa-search', iTopWebPage::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES); $oP->add("
    \n"); $oP->add("
    \n"); - $oP->add(' '.Dict::Format('UI:Search:Ongoing', htmlentities($sFullText, ENT_QUOTES, 'UTF-8')).''); + $oP->add(' '.Dict::Format('UI:Search:Ongoing', utils::EscapeHtml($sFullText)).''); $oP->add("
    \n"); $oP->add("
    \n"); $oP->add("
     
    \n"); - $oP->add("

    ".Dict::Format('UI:FullTextSearchTitle_Text', htmlentities($sFullText, ENT_QUOTES, 'UTF-8'))."

    "); + $oP->add("

    ".Dict::Format('UI:FullTextSearchTitle_Text', utils::EscapeHtml($sFullText))."

    "); $oP->add("
    \n"); $oP->add("
    \n"); $sJSClass = addslashes($sClassName); $sJSNeedles = json_encode($aFullTextNeedles); $oP->add_ready_script( -<<UpdateContextFromUser(); $aSelectedObj = utils::ReadMultipleSelection($oFullSetFilter); $sCancelUrl = "./UI.php?operation=search&filter=".urlencode($sFilter)."&".$oAppContext->GetForLink(); - $aContext = array('filter' => htmlentities($sFilter, ENT_QUOTES, 'UTF-8')); + $aContext = array('filter' => utils::EscapeHtml($sFilter)); cmdbAbstractObject::DisplayBulkModifyForm($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $sCancelUrl, array(), $aContext); } @@ -1986,7 +1986,7 @@ class UI $aSelectedObj = explode(',', $sSelectedObj); $sCancelUrl = "./UI.php?operation=search&filter=".urlencode($sFilter)."&".$oAppContext->GetForLink(); $aContext = array( - 'filter' => htmlentities($sFilter, ENT_QUOTES, 'UTF-8'), + 'filter' => utils::EscapeHtml($sFilter), 'selectObj' => $sSelectedObj, ); cmdbAbstractObject::DoBulkModify($oP, $sClass, $aSelectedObj, 'preview_or_modify_all', $bPreview, $sCancelUrl, $aContext); diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index f3a7de2e7..7b1187593 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -238,7 +238,7 @@ try if (($bFirstLineAsHeader) && ($index == 1)) { $aColumns[] = ["label" => sprintf($sFormat, $index)]; foreach ($aRow as $sCell) { - $aColumns[] = ["label" => htmlentities($sCell, ENT_QUOTES, 'UTF-8')]; + $aColumns[] = ["label" => utils::EscapeHtml($sCell)]; } $iNbCols = count($aRow); } else { @@ -248,7 +248,7 @@ try } $aTableRow[] = sprintf($sFormat, $index); foreach ($aRow as $sCell) { - $aTableRow[] = htmlentities($sCell, ENT_QUOTES, 'UTF-8'); + $aTableRow[] = utils::EscapeHtml($sCell); } $aTableData[$index] = $aTableRow; } @@ -322,8 +322,8 @@ try $aTableRow['HeaderFields'] = utils::HtmlEntities($sField); $aTableRow['HeaderMapipngs'] = BlockRenderer::RenderBlockTemplates(GetMappingForField($sClassName, $sField, $index, $bAdvanced, $sDefaultChoice)); $aTableRow['HeaderSearch'] = ''; - $aTableRow['DataLine1'] = (isset($aData[$iStartLine][$index - 1]) ? htmlentities($aData[$iStartLine][$index - 1], ENT_QUOTES, 'UTF-8') : ' '); - $aTableRow['DataLine2'] = (isset($aData[$iStartLine + 1][$index - 1]) ? htmlentities($aData[$iStartLine + 1][$index - 1], ENT_QUOTES, 'UTF-8') : ' '); + $aTableRow['DataLine1'] = (isset($aData[$iStartLine][$index - 1]) ? utils::EscapeHtml($aData[$iStartLine][$index - 1]) : ' '); + $aTableRow['DataLine2'] = (isset($aData[$iStartLine + 1][$index - 1]) ? utils::EscapeHtml($aData[$iStartLine + 1][$index - 1]) : ' '); $aTableData[$index] = $aTableRow; $index++; } diff --git a/pages/ajax.document.php b/pages/ajax.document.php index 9257b0a26..3706532ba 100644 --- a/pages/ajax.document.php +++ b/pages/ajax.document.php @@ -107,7 +107,7 @@ try catch (Exception $e) { // note: transform to cope with XSS attacks - echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8'); + echo utils::EscapeHtml($e->GetMessage()); IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); } diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 72d2f942e..936384cc4 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -1439,7 +1439,7 @@ EOF; $sEnlargeButton = ''; if ($bEnableEnlarge) { - $sEnlargeButton = " "; + $sEnlargeButton = " "; } if ($oSet->Count() > 0) { @@ -2229,17 +2229,16 @@ EOF $iAttId = $oAttachment->DBInsert(); $aResult['uploaded'] = 1; - $aResult['msg'] = htmlentities($oDoc->GetFileName(), ENT_QUOTES, 'UTF-8'); + $aResult['msg'] = utils::EscapeHtml($oDoc->GetFileName()); $aResult['fileName'] = $oDoc->GetFileName(); $aResult['url'] = utils::GetAbsoluteUrlAppRoot().INLINEIMAGE_DOWNLOAD_URL.$iAttId.'&s='.$oAttachment->Get('secret'); - if (is_array($aDimensions)) - { + if (is_array($aDimensions)) { $aResult['width'] = $aDimensions['width']; $aResult['height'] = $aDimensions['height']; } - IssueLog::Trace('InlineImage created', LogChannels::INLINE_IMAGE, array( - '$operation' => $operation, + IssueLog::Trace('InlineImage created', LogChannels::INLINE_IMAGE, array( + '$operation' => $operation, '$aResult' => $aResult, 'secret' => $oAttachment->Get('secret'), 'temp_id' => $sTempId, @@ -2432,9 +2431,8 @@ EOF while ($oAttachment = $oSet->Fetch()) { $oDoc = $oAttachment->Get('contents'); - if ($oDoc->GetMainMimeType() == 'image') - { - $sDocName = addslashes(htmlentities($oDoc->GetFileName(), ENT_QUOTES, 'UTF-8')); + if ($oDoc->GetMainMimeType() == 'image') { + $sDocName = addslashes(utils::EscapeHtml($oDoc->GetFileName())); $iAttId = $oAttachment->GetKey(); $sSecret = $oAttachment->Get('secret'); $oPage->add("
    \"$sDocName\"
    "); @@ -2667,9 +2665,8 @@ EOF } $oKPI->ComputeAndReport('Data fetch and format'); $oPage->output(); -} catch (Exception $e) -{ +} catch (Exception $e) { // note: transform to cope with XSS attacks - echo htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8'); + echo utils::EscapeHtml($e->GetMessage()); IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); } diff --git a/pages/ajax.searchform.php b/pages/ajax.searchform.php index c63815c1e..82ba670bf 100644 --- a/pages/ajax.searchform.php +++ b/pages/ajax.searchform.php @@ -94,41 +94,33 @@ try $oCollapsible = CollapsibleSectionUIBlockFactory::MakeStandard(Dict::S('UI:RunQuery:MoreInfo')); $oPage->AddSubBlock($oCollapsible); - $oHtml = new Html(Dict::S('UI:RunQuery:DevelopedQuery').htmlentities($oFilter->ToOQL(), ENT_QUOTES, 'UTF-8')); + $oHtml = new Html(Dict::S('UI:RunQuery:DevelopedQuery').utils::EscapeHtml($oFilter->ToOQL())); $oCollapsible->AddSubBlock($oHtml); - - /*$oPage->StartCollapsibleSection(Dict::S('UI:RunQuery:MoreInfo'), false, 'SearchQuery'); - $oPage->p(Dict::S('UI:RunQuery:DevelopedQuery').htmlentities($oFilter->ToOQL(), ENT_QUOTES, 'UTF-8')); - $oPage->EndCollapsibleSection();*/ } $oPage->output(); -} catch (AjaxSearchException $e) -{ +} catch (AjaxSearchException $e) { http_response_code($e->getCode()); // note: transform to cope with XSS attacks - echo '
    ' . htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8') . '
    '; + echo '
    '.utils::EscapeHtml($e->GetMessage()).'
    '; IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); -} catch (SecurityException $e) -{ +} catch (SecurityException $e) { http_response_code(403); // note: transform to cope with XSS attacks - echo '
    ' . htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8') . '
    '; + echo '
    '.utils::EscapeHtml($e->GetMessage()).'
    '; IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); -} catch (MySQLException $e) -{ +} catch (MySQLException $e) { http_response_code(500); // Sanytize error: $sMsg = $e->GetMessage(); $sMsg = preg_replace("@^.* mysql_error = @", '', $sMsg); // note: transform to cope with XSS attacks - echo '
    '.htmlentities($sMsg, ENT_QUOTES, 'utf-8').'
    '; + echo '
    '.utils::EscapeHtml($sMsg).'
    '; IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); -} catch (Exception $e) -{ +} catch (Exception $e) { http_response_code(500); // note: transform to cope with XSS attacks - echo '
    ' . htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8') . '
    '; + echo '
    '.utils::EscapeHtml($e->GetMessage()).'
    '; IssueLog::Error($e->getMessage()."\nDebug trace:\n".$e->getTraceAsString()); } \ No newline at end of file diff --git a/pages/csvimport.php b/pages/csvimport.php index 5c58d66bf..31b3e968d 100644 --- a/pages/csvimport.php +++ b/pages/csvimport.php @@ -374,7 +374,7 @@ try { ); $oBulk->SetReportHtml(); - $oPage->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", htmlentities($sCSVDataTruncated, ENT_QUOTES, 'UTF-8'), "csvdata_truncated")); + $oPage->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", utils::EscapeHtml($sCSVDataTruncated), "csvdata_truncated")); $aRes = $oBulk->Process($oMyChange); $aColumns = []; @@ -527,19 +527,19 @@ try { $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("transaction_id", utils::GetNewTransactionId())); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("step", ($iCurrentStep + 1))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", htmlentities($sSeparator, ENT_QUOTES, 'UTF-8'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", htmlentities($sTextQualifier, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", utils::EscapeHtml($sSeparator))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", utils::EscapeHtml($sTextQualifier))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("header_line", $bHeaderLine)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("nb_skipped_lines", utils::ReadParam('nb_skipped_lines', '0'))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("box_skiplines", utils::ReadParam('box_skiplines', '0'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", htmlentities($sCSVDataTruncated, ENT_QUOTES, 'UTF-8'), "csvdata_truncated")); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", htmlentities($sCSVData, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", utils::EscapeHtml($sCSVDataTruncated), "csvdata_truncated")); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", utils::EscapeHtml($sCSVData))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("encoding", $sEncoding)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("synchro_scope", $sSynchroScope)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("class_name", $sClassName)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("advanced", $bAdvanced)); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", htmlentities($sDateTimeFormat, ENT_QUOTES, 'UTF-8'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", htmlentities($sCustomDateTimeFormat, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", utils::EscapeHtml($sDateTimeFormat))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", utils::EscapeHtml($sCustomDateTimeFormat))); if (!empty($sSynchroScope)) { foreach ($aSynchroUpdate as $sKey => $value) { @@ -644,7 +644,7 @@ try { $oDlg = UIContentBlockUIBlockFactory::MakeStandard("dlg_confirmation")->SetHasForcedDiv(true); $oPage->AddSubBlock($oDlg); $oDlg->AddSubBlock(new Html($sMessage)); - $oDlg->AddSubBlock(new Html(htmlentities(Dict::S('UI:CSVImportConfirmMessage'), ENT_QUOTES, 'UTF-8'))); + $oDlg->AddSubBlock(new Html(utils::EscapeHtml(Dict::S('UI:CSVImportConfirmMessage')))); $oDlgConfirm = UIContentBlockUIBlockFactory::MakeStandard("confirmation_chart")->SetHasForcedDiv(true); $oDlg->AddSubBlock($oDlgConfirm); @@ -791,7 +791,7 @@ EOF $oField = FieldUIBlockFactory::MakeLarge(Dict::S('UI:CSVImport:LinesNotImported+')); $oCollapsibleSection->AddSubBlock($oField); - $oText = new TextArea("", htmlentities(implode("\n", $aResult), ENT_QUOTES, 'UTF-8'), "", 150, 50); + $oText = new TextArea("", utils::EscapeHtml(implode("\n", $aResult)), "", 150, 50); $oField->AddSubBlock($oText); } } @@ -882,17 +882,17 @@ EOF $oForm->AddSubBlock($oDivMapping); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("step", "4")); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", htmlentities($sSeparator, ENT_QUOTES, 'UTF-8'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", htmlentities($sTextQualifier, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", utils::EscapeHtml($sSeparator))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", utils::EscapeHtml($sTextQualifier))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("header_line", $bHeaderLine)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("nb_skipped_lines", utils::ReadParam('nb_skipped_lines', '0'))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("box_skiplines", utils::ReadParam('box_skiplines', '0'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", htmlentities($sCSVDataTruncated, ENT_QUOTES, 'UTF-8'), "csvdata_truncated")); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", htmlentities($sCSVData, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", utils::EscapeHtml($sCSVDataTruncated), "csvdata_truncated")); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", utils::EscapeHtml($sCSVData))); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("encoding", $sEncoding)); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("synchro_scope", $sSynchroScope)); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", htmlentities($sDateTimeFormat, ENT_QUOTES, 'UTF-8'))); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", htmlentities($sCustomDateTimeFormat, ENT_QUOTES, 'UTF-8'))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", utils::EscapeHtml($sDateTimeFormat))); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", utils::EscapeHtml($sCustomDateTimeFormat))); if (!empty($sSynchroScope)) { foreach ($aSynchroUpdate as $sKey => $value) { @@ -1259,10 +1259,10 @@ EOF $sSeparator = "tab"; } $sOtherSeparator = in_array($sSeparator, array(',', ';', "\t")) ? '' : $sSeparator; - $aSep['other'] = Dict::S('UI:CSVImport:SeparatorOther').' '; + $aSep['other'] = Dict::S('UI:CSVImport:SeparatorOther').' '; foreach ($aSep as $sVal => $sLabel) { - $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "separator", htmlentities($sVal, ENT_QUOTES, 'UTF-8'), $sLabel, "radio"); + $oRadio = InputUIBlockFactory::MakeForInputWithLabel($sLabel, "separator", utils::EscapeHtml($sVal), $sLabel, "radio"); $oRadio->GetInput()->SetIsChecked(($sVal == $sSeparator)); $oRadio->SetBeforeInput(false); $oRadio->GetInput()->AddCSSClass('ibo-input--label-right'); @@ -1277,13 +1277,12 @@ EOF $oMulticolumn->AddColumn(ColumnUIBlockFactory::MakeForBlock($oFieldSetTextQualifier)); $aQualifiers = array( - '"' => Dict::S('UI:CSVImport:QualifierDoubleQuote+'), + '"' => Dict::S('UI:CSVImport:QualifierDoubleQuote+'), '\'' => Dict::S('UI:CSVImport:QualifierSimpleQuote+'), ); - $aQualifiers['other'] = Dict::S('UI:CSVImport:QualifierOther').' + $aQualifiers['other'] = Dict::S('UI:CSVImport:QualifierOther').' GetInput()->SetIsChecked(($sVal == $sTextQualifier)); $oRadio->SetBeforeInput(false); $oRadio->GetInput()->AddCSSClass('ibo-input-checkbox'); @@ -1320,8 +1319,8 @@ EOF $sDateTimeFormat = utils::ReadParam('date_time_format', 'default'); $sCustomDateTimeFormat = utils::ReadParam('custom_date_time_format', (string)AttributeDateTime::GetFormat(), false, 'raw_data'); - $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); - $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); + $sDefaultFormat = utils::EscapeHtml((string)AttributeDateTime::GetFormat()); + $sExample = utils::EscapeHtml(date((string)AttributeDateTime::GetFormat())); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('UI:CSVImport:DefaultDateTimeFormat_Format_Example', $sDefaultFormat, $sExample), "date_time_format", "default", "radio_date_time_std", "radio"); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->SetBeforeInput(false); @@ -1329,7 +1328,7 @@ EOF $oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock(new Html('
    ')); - $sFormatInput = ''; + $sFormatInput = ''; $oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('UI:CSVImport:CustomDateTimeFormat', $sFormatInput), "date_time_format", "custom", "radio_date_time_custom", "radio"); $oRadioCustom->SetDescription(Dict::S('UI:CSVImport:CustomDateTimeFormatTooltip')); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); @@ -1340,8 +1339,8 @@ EOF $oPage->add_ready_script("$('#custom_date_time_format').on('click', function() { DoPreview(); });"); $oPage->add_ready_script("$('#radio_date_time_std').on('click', function() { DoPreview(); });"); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", htmlentities($sCSVDataTruncated, ENT_QUOTES, 'UTF-8'), "csvdata_truncated")); - $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", htmlentities($sUTF8Data, ENT_QUOTES, 'UTF-8'), 'csvdata')); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata_truncated", utils::EscapeHtml($sCSVDataTruncated), "csvdata_truncated")); + $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("csvdata", utils::EscapeHtml($sUTF8Data), 'csvdata')); // The encoding has changed, keep that information within the wizard $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("encoding", "UTF-8")); $oForm->AddSubBlock(InputUIBlockFactory::MakeForHidden("class_name", $sClassName)); @@ -1530,10 +1529,10 @@ EOF $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("encoding", 'UTF-8')); $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("step", '2')); - $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", htmlentities($sSeparator, ENT_QUOTES, 'UTF-8'))); - $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", htmlentities($sTextQualifier, ENT_QUOTES, 'UTF-8'))); - $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", htmlentities($sDateTimeFormat, ENT_QUOTES, 'UTF-8'))); - $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", htmlentities($sCustomDateTimeFormat, ENT_QUOTES, 'UTF-8'))); + $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("separator", utils::EscapeHtml($sSeparator))); + $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("text_qualifier", utils::EscapeHtml($sTextQualifier))); + $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("date_time_format", utils::EscapeHtml($sDateTimeFormat))); + $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("custom_date_time_format", utils::EscapeHtml($sCustomDateTimeFormat))); $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("header_line", $bHeaderLine)); $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("nb_skipped_lines", utils::ReadParam('nb_skipped_lines', '0'))); $oFormPaste->AddSubBlock(InputUIBlockFactory::MakeForHidden("box_skiplines", utils::ReadParam('box_skiplines', '0'))); diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index 0b03e8028..611dde03f 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -1822,7 +1822,7 @@ EOF; echo " \n"; echo " \n"; echo "

    DOM - Original values

    \n"; - echo "
    ".htmlentities($sDOMOriginal)."
    \n"; + echo "
    ".utils::EscapeHtml($sDOMOriginal)."
    \n"; echo " \n"; echo " ⇒ ⇒ ⇒\n"; echo " \n"; @@ -1830,17 +1830,17 @@ EOF; echo " \n"; echo " \n"; echo "

    DOM - Altered with various changes

    \n"; - echo "
    ".htmlentities($sDOMModified)."
    \n"; + echo "
    ".utils::EscapeHtml($sDOMModified)."
    \n"; echo " \n"; echo " \n"; echo "

    DOM - Rebuilt from the Delta

    \n"; - echo "
    ".htmlentities($sDOMRebuilt)."
    \n"; + echo "
    ".utils::EscapeHtml($sDOMRebuilt)."
    \n"; echo " \n"; echo " \n"; echo "
    \n"; echo " \n"; echo "

    Delta (Computed by ModelFactory)

    \n"; - echo "
    ".htmlentities($sDeltaXML)."
    \n"; + echo "
    ".utils::EscapeHtml($sDeltaXML)."
    \n"; echo " \n"; echo " ⇒ ⇒ ⇒\n"; echo " \n"; diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 093f9f8ce..725214e0c 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -1020,23 +1020,21 @@ class SetupUtils //-- DB connection params $oPage->add(''); - $oPage->add('Server Name:'); - $oPage->add('Login:'); + $oPage->add('Login:'); - $oPage->add('Password:'); + $oPage->add('Password:'); $oPage->add(''); //-- TLS params (N°1260) $sTlsEnabledChecked = $bTlsEnabled ? ' checked' : ''; - $sTlsCaDisabled = $bTlsEnabled ? '' : ' disabled'; + $sTlsCaDisabled = $bTlsEnabled ? '' : ' disabled'; $oPage->add('
    '); $oPage->add(''); $oPage->add(''); $oPage->add(''); $oPage->add(''); $oPage->add('
    '); @@ -1047,22 +1045,18 @@ class SetupUtils $oPage->add(''); $oPage->add('
    Database'); $oPage->add(''); - if ($bIsItopInstall) - { + if ($bIsItopInstall) { $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add(''); - $oPage->add(''); - } - else - { - $oPage->add(''); + $oPage->add(''); + } else { + $oPage->add(''); } $oPage->add('
    Database Name:
    Database Name:
    '); $oPage->add('
    '); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    '); $oPage->add('
    '); $oPage->add(''); @@ -1476,23 +1470,18 @@ JS } } - if ($checks['databases'] == null) - { - $sDBNameInput = ''; + if ($checks['databases'] == null) { + $sDBNameInput = ''; $oPage->add_ready_script( -<<Error:Not enough rights to enumerate the databases
'); JS ); - } - else - { + } else { $sDBNameInput = '
'; diff --git a/setup/wizardcontroller.class.inc.php b/setup/wizardcontroller.class.inc.php index 7275a115f..ca4664323 100644 --- a/setup/wizardcontroller.class.inc.php +++ b/setup/wizardcontroller.class.inc.php @@ -201,25 +201,22 @@ HTML; $oPage->add('
'); $oStep->Display($oPage); $oPage->add('
'); - + // Add the back / next buttons and the hidden form // to store the parameters $oPage->add(''); $oPage->add(''); - foreach($this->aParameters as $sCode => $value) - { - $oPage->add(''); + foreach ($this->aParameters as $sCode => $value) { + $oPage->add(''); } - $oPage->add(''); + $oPage->add(''); $oPage->add(''); - if ((count($this->aSteps) > 0) && ($oStep->CanMoveBackward())) - { + if ((count($this->aSteps) > 0) && ($oStep->CanMoveBackward())) { $oPage->add(''); } - if ($oStep->CanMoveForward()) - { - $oPage->add(''); + if ($oStep->CanMoveForward()) { + $oPage->add(''); } $oPage->add('
'); $oPage->add(""); diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index d01d7aab2..681cd0b55 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -304,13 +304,10 @@ HTML $sChecked = ($bCanBackup && $bDBBackup) ? ' checked ' : ''; $sDisabled = $bCanBackup ? '' : ' disabled '; $oPage->add(''); - $oPage->add('
Save the backup to:
'); + $oPage->add('
Save the backup to:
'); $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); $sMessage = ''; - if ($fFreeSpace !== false) - { + if ($fFreeSpace !== false) { $sMessage .= SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath); } $oPage->add($sMySQLDumpMessage.''.$sMessage.''); @@ -332,17 +329,16 @@ JS switch($sCode) { case 'check_path': - $sPreviousVersionDir = $aParameters['previous_version_dir']; - $aPreviousInstance = SetupUtils::GetPreviousInstance($sPreviousVersionDir); - if ($aPreviousInstance['found']) - { - $sDBServer = htmlentities($aPreviousInstance['db_server'], ENT_QUOTES, 'UTF-8'); - $sDBUser = htmlentities($aPreviousInstance['db_user'], ENT_QUOTES, 'UTF-8'); - $sDBPwd = htmlentities($aPreviousInstance['db_pwd'], ENT_QUOTES, 'UTF-8'); - $sDBName = htmlentities($aPreviousInstance['db_name'], ENT_QUOTES, 'UTF-8'); - $sDBPrefix = htmlentities($aPreviousInstance['db_prefix'], ENT_QUOTES, 'UTF-8'); - $oPage->add_ready_script( -<<add_ready_script( + <<add_ready_script( -<<add_ready_script( + <<add_ready_script( -<<add_ready_script( + << 0) || (count($aChanges['removed']) > 0) || (count($aChanges['modified']) > 0)) ) - { + if (($aChanges !== false) && ( (count($aChanges['added']) > 0) || (count($aChanges['removed']) > 0) || (count($aChanges['modified']) > 0)) ) { // Some changes were detected, prompt the user to keep or discard them $oPage->p(" Some modifications were detected between the ".ITOP_APPLICATION." version in '$sPreviousVersionDir' and a genuine $sInstalledVersion version."); $oPage->p("What do you want to do?"); @@ -558,41 +550,36 @@ EOF $sChecked = ($this->oWizard->GetParameter('upgrade_type') == 'keep-previous') ? ' checked ' : ''; $sDisabled = (count($aErrors) > 0) ? ' disabled ' : ''; - $oPage->p(''); - $oPage->add(''); + $oPage->p(''); + $oPage->add(''); - $oPage->add(''); + $oPage->add(''); - if (count($aErrors) > 0) - { + if (count($aErrors) > 0) { $oPage->p("Cannot copy the installed version due to the following access rights issue(s):"); - foreach($aErrors as $sDir => $oCheckResult) - { + foreach ($aErrors as $sDir => $oCheckResult) { $oPage->p(' '.$oCheckResult->sLabel); } } $sChecked = ($this->oWizard->GetParameter('upgrade_type') == 'use-compatible') ? ' checked ' : ''; - $oPage->p(''); + $oPage->p(''); - $oPage->add(''); - $oPage->add(''); + $oPage->add(''); + $oPage->add(''); $oPage->add('
Details of the modifications
'); - if (count($aChanges['added']) > 0) - { + if (count($aChanges['added']) > 0) { $oPage->add('
    New files added:'); - foreach($aChanges['added'] as $sFilePath => $void) - { + foreach ($aChanges['added'] as $sFilePath => $void) { $oPage->add('
  • '.$sFilePath.'
  • '); } $oPage->add('
'); } - if (count($aChanges['removed']) > 0) - { + if (count($aChanges['removed']) > 0) { $oPage->add('
    Deleted files:'); - foreach($aChanges['removed'] as $sFilePath => $void) + foreach ($aChanges['removed'] as $sFilePath => $void) { $oPage->add('
  • '.$sFilePath.'
  • '); } @@ -917,9 +904,9 @@ class WizStepAdminAccount extends WizardStep $oPage->add('
    '); $oPage->add('Administrator Account'); $oPage->add(''); - $oPage->add(''); - $oPage->add(''); - $oPage->add(''); + $oPage->add(''); + $oPage->add(''); + $oPage->add(''); $sSourceDir = APPROOT.'dictionaries/'; $aLanguages = SetupUtils::GetAvailableLanguages($sSourceDir); $oPage->add('
    Login:
    Password:
    Confirm password:
    Login:
    Password:
    Confirm password:
    Language: '); @@ -928,7 +915,7 @@ class WizStepAdminAccount extends WizardStep $oPage->add('
    '); $oPage->add('
    '); $oPage->add_ready_script( -<<add('
    '); $oPage->add('Application URL'); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    URL:
    URL:
    '); $oPage->add('
    Change the value above if the end-users will be accessing the application by another path due to a specific configuration of the web server.
    '); $oPage->add('
    '); $oPage->add('
    '); $oPage->add('Path to Graphviz\' dot application'); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add(''); $oPage->add('
    Path:
    Path:
    '); $oPage->add(''); $oPage->add('
    '); $oPage->add('
    '); $oPage->add('Sample Data'); - $sChecked = ($sSampleData == 'yes') ? 'checked ' : ''; - $oPage->p('
    '); $sAuthentToken = $this->oWizard->GetParameter('authent', ''); $oPage->add(''); $oPage->add_ready_script( -<<add('
    '); $oPage->add('Application URL'); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add('
    URL:
    URL:
    '); $oPage->add('
    Change the value above if the end-users will be accessing the application by another path due to a specific configuration of the web server.
    '); $oPage->add('
    '); $oPage->add('
    '); $oPage->add('Path to Graphviz\' dot application'); $oPage->add(''); - $oPage->add(''); + $oPage->add(''); $oPage->add(''); $oPage->add('
    Path:
    Path:
    '); $oPage->add(''); @@ -1212,7 +1199,7 @@ class WizStepUpgradeMiscParams extends AbstractWizStepMiscParams $sAuthentToken = $this->oWizard->GetParameter('authent', ''); $oPage->add(''); $oPage->add_ready_script( -<< $aChoice) - { + foreach ($aOptions as $index => $aChoice) { $sAttributes = ''; $sChoiceId = $sParentId.self::$SEP.$index; - $sDataId = 'data-id="'.htmlentities($aChoice['extension_code'], ENT_QUOTES, 'UTF-8').'"'; - $sId = htmlentities($aChoice['extension_code'], ENT_QUOTES, 'UTF-8'); + $sDataId = 'data-id="'.utils::EscapeHtml($aChoice['extension_code']).'"'; + $sId = utils::EscapeHtml($aChoice['extension_code']); $bIsDefault = array_key_exists($sChoiceId, $aDefaults); $bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId); $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || ($this->bUpgrade && $bIsDefault); $bDisabled = false; - if ($bMandatory) - { + if ($bMandatory) { $oPage->add('
     '); $bDisabled = true; - } - else if ($bSelected) - { + } else if ($bSelected) { $oPage->add('
     '); - } - else - { + } else { $oPage->add('
     '); } $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId, $bDisabled); @@ -2081,35 +2061,30 @@ EOF } } - if (!array_key_exists($sChoiceName, $aDefaults) || ($aDefaults[$sChoiceName] == $sChoiceIdNone)) - { + if (!array_key_exists($sChoiceName, $aDefaults) || ($aDefaults[$sChoiceName] == $sChoiceIdNone)) { // The "none" choice does not disable the selection !! $sDisabled = ''; $bDisabled = false; } - foreach($aAlternatives as $index => $aChoice) - { + foreach ($aAlternatives as $index => $aChoice) { $sAttributes = ''; $sChoiceId = $sParentId.self::$SEP.$index; - $sDataId = 'data-id="'.htmlentities($aChoice['extension_code'], ENT_QUOTES, 'UTF-8').'"'; - $sId = htmlentities($aChoice['extension_code'], ENT_QUOTES, 'UTF-8'); + $sDataId = 'data-id="'.utils::EscapeHtml($aChoice['extension_code']).'"'; + $sId = utils::EscapeHtml($aChoice['extension_code']); - if ($sChoiceName == null) - { + if ($sChoiceName == null) { $sChoiceName = $sChoiceId; // All radios share the same name } $bIsDefault = array_key_exists($sChoiceName, $aDefaults) && ($aDefaults[$sChoiceName] == $sChoiceId); $bSelected = isset($aSelectedComponents[$sChoiceName]) && ($aSelectedComponents[$sChoiceName] == $sChoiceId); - if ( !isset($aSelectedComponents[$sChoiceName]) && ($sChoiceIdNone != null)) - { + if (!isset($aSelectedComponents[$sChoiceName]) && ($sChoiceIdNone != null)) { // No choice selected, select the "None" option $bSelected = ($sChoiceId == $sChoiceIdNone); } $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || ($this->bUpgrade && $bIsDefault); - if ($bSelected) - { + if ($bSelected) { $sAttributes = ' checked '; } $sHidden = ''; @@ -2129,12 +2104,11 @@ EOF { $sMoreInfo = (isset($aChoice['more_info']) && ($aChoice['more_info'] != '')) ? 'More information' : ''; $sSourceLabel = isset($aChoice['source_label']) ? $aChoice['source_label'] : ''; - $sId = htmlentities($aChoice['extension_code'], ENT_QUOTES, 'UTF-8'); - $oPage->add(' '.$sMoreInfo); - $sDescription = isset($aChoice['description']) ? htmlentities($aChoice['description'], ENT_QUOTES, 'UTF-8') : ''; + $sId = utils::EscapeHtml($aChoice['extension_code']); + $oPage->add(' '.$sMoreInfo); + $sDescription = isset($aChoice['description']) ? utils::EscapeHtml($aChoice['description']) : ''; $oPage->add('
    '.$sDescription.''); - if (isset($aChoice['sub_options'])) - { + if (isset($aChoice['sub_options'])) { $this->DisplayOptions($oPage, $aChoice['sub_options'], $aSelectedComponents, $aDefaults, $sChoiceId, $bDisabled); } $oPage->add('
    '); @@ -2295,8 +2269,7 @@ class WizStepSummary extends WizardStep if (count($aMiscOptions) > 0) { $oPage->add('
    Miscellaneous Options
      '); - foreach($aMiscOptions as $sKey => $sValue) - { + foreach ($aMiscOptions as $sKey => $sValue) { $oPage->add('
    • '.$sKey.': '.$sValue.'
    • '); } $oPage->add('
    '); @@ -2305,8 +2278,7 @@ class WizStepSummary extends WizardStep $aSelectedModules = $aInstallParams['selected_modules']; - if (isset($aMiscOptions['generate_config'])) - { + if (isset($aMiscOptions['generate_config'])) { $oDoc = new DOMDocument('1.0', 'UTF-8'); $oDoc->preserveWhiteSpace = false; $oDoc->formatOutput = true; @@ -2315,7 +2287,7 @@ class WizStepSummary extends WizardStep $oParams->ToXML($oDoc, null, 'installation'); $sXML = $oDoc->saveXML(); $oPage->add('
    XML Config file
      ');
      -			$oPage->add(htmlentities($sXML, ENT_QUOTES, 'UTF-8'));
      +			$oPage->add(utils::EscapeHtml($sXML));
       			$oPage->add('
    '); } @@ -2330,13 +2302,12 @@ class WizStepSummary extends WizardStep $oPage->add('
    '); $sJSONData = json_encode($aInstallParams); - $oPage->add(''); + $oPage->add(''); $sAuthentToken = $this->oWizard->GetParameter('authent', ''); $oPage->add(''); - if (!$this->CheckDependencies()) - { + if (!$this->CheckDependencies()) { $oPage->error($this->sDependencyIssue); } @@ -2459,12 +2430,11 @@ JS $oParameters->LoadFromHash(json_decode($sJSONParameters, true /* bAssoc */)); $oInstaller = new ApplicationInstaller($oParameters); $aRes = $oInstaller->ExecuteStep($sStep); - if (($aRes['status'] != ApplicationInstaller::ERROR) && ($aRes['next-step'] != '')) - { + if (($aRes['status'] != ApplicationInstaller::ERROR) && ($aRes['next-step'] != '')) { // Tell the web page to move the progress bar and to launch the next step - $sMessage = addslashes(htmlentities($aRes['next-step-label'], ENT_QUOTES, 'UTF-8')); + $sMessage = addslashes(utils::EscapeHtml($aRes['next-step-label'])); $oPage->add_ready_script( -<<add_ready_script( -<<', $sMessage); $oPage->add_ready_script( -<<oWizard->GetParameter('application_url').'pages/UI.php">'; - $sForm .= ''; - $sForm .= ''; + $sForm .= ''; + $sForm .= ''; $sForm .= "
"; $sForm .= ''; diff --git a/sources/Application/Search/searchform.class.inc.php b/sources/Application/Search/searchform.class.inc.php index eb14c5e25..a6f908e31 100644 --- a/sources/Application/Search/searchform.class.inc.php +++ b/sources/Application/Search/searchform.class.inc.php @@ -119,7 +119,7 @@ class SearchForm } $sContext = $oAppContext->GetForLink(); - $sJsonExtraParams = htmlentities(json_encode($aListParams), ENT_QUOTES); + $sJsonExtraParams = utils::EscapeHtml(json_encode($aListParams)); $sOuterSelector = $aExtraParams['result_list_outer_selector']; if (isset($aExtraParams['search_header_force_dropdown'])) { diff --git a/sources/Application/TwigBase/Controller/Controller.php b/sources/Application/TwigBase/Controller/Controller.php index 2eab21aed..6a2dad13b 100644 --- a/sources/Application/TwigBase/Controller/Controller.php +++ b/sources/Application/TwigBase/Controller/Controller.php @@ -182,7 +182,7 @@ abstract class Controller http_response_code(500); $oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError')); $oP->add("

".Dict::S('UI:FatalErrorMessage')."

\n"); - $oP->add(get_class($e).' : '.htmlentities($e->GetMessage(), ENT_QUOTES, 'utf-8')); + $oP->add(get_class($e).' : '.utils::EscapeHtml($e->GetMessage())); $oP->output(); IssueLog::Error($e->getMessage()); diff --git a/sources/Application/WebPage/NiceWebPage.php b/sources/Application/WebPage/NiceWebPage.php index de11f57d1..abae1ab38 100644 --- a/sources/Application/WebPage/NiceWebPage.php +++ b/sources/Application/WebPage/NiceWebPage.php @@ -227,8 +227,7 @@ EOF foreach($aChoices as $sKey => $sValue) { $sSelected = ($sKey == $sDefaultValue) ? " SELECTED" : ""; - $this->add(""); + $this->add(""); } $this->add(""); } diff --git a/sources/Application/WebPage/iTopWizardWebPage.php b/sources/Application/WebPage/iTopWizardWebPage.php index e2660fead..af9dd10ec 100644 --- a/sources/Application/WebPage/iTopWizardWebPage.php +++ b/sources/Application/WebPage/iTopWizardWebPage.php @@ -50,7 +50,7 @@ class iTopWizardWebPage extends iTopWebPage $sStyle = ($iIndex == $this->m_iCurrentStep) ? 'wizActiveStep' : 'wizStep'; $aSteps[] = "
$sStepTitle
"; } - $sWizardHeader = "

".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."

\n".implode("
", $aSteps)."
\n"; + $sWizardHeader = "

".utils::EscapeHtml($this->s_title)."

\n".implode("
", $aSteps)."
\n"; $this->s_content = "$sWizardHeader
".$this->s_content."
"; parent::output(); } diff --git a/sources/Renderer/Bootstrap/FieldRenderer/BsFileUploadFieldRenderer.php b/sources/Renderer/Bootstrap/FieldRenderer/BsFileUploadFieldRenderer.php index f1359df80..a7b1c902b 100644 --- a/sources/Renderer/Bootstrap/FieldRenderer/BsFileUploadFieldRenderer.php +++ b/sources/Renderer/Bootstrap/FieldRenderer/BsFileUploadFieldRenderer.php @@ -397,14 +397,13 @@ HTML /** @var \ormDocument $oDoc */ $oDoc = $oAttachment->Get('contents'); - $sFileName = htmlentities($oDoc->GetFileName(), ENT_QUOTES, 'UTF-8'); + $sFileName = utils::EscapeHtml($oDoc->GetFileName()); $sDocDownloadUrl = str_replace('-sAttachmentId-', $iAttId, $this->oField->GetDownloadEndpoint()); $sAttachmentThumbUrl = utils::GetAbsoluteUrlAppRoot().AttachmentPlugIn::GetFileIcon($sFileName); $bHasPreview = false; - if ($oDoc->IsPreviewAvailable()) - { + if ($oDoc->IsPreviewAvailable()) { $bHasPreview = true; $iMaxSizeForPreview = MetaModel::GetModuleSetting('itop-attachments', 'icon_preview_max_size', AbstractAttachmentsRenderer::DEFAULT_MAX_SIZE_FOR_PREVIEW); if ($oDoc->GetSize() <= $iMaxSizeForPreview) diff --git a/sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php b/sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php index 450e4f520..1d5ca6b22 100644 --- a/sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php +++ b/sources/Renderer/Bootstrap/FieldRenderer/BsLinkedSetFieldRenderer.php @@ -54,7 +54,7 @@ class BsLinkedSetFieldRenderer extends BsFieldRenderer $aItemIds = array(); $this->PrepareItems($aItems, $aItemIds); $sItemsAsJson = json_encode($aItems); - $sItemIdsAsJson = htmlentities(json_encode(array('current' => $aItemIds)), ENT_QUOTES, 'UTF-8'); + $sItemIdsAsJson = utils::EscapeHtml(json_encode(array('current' => $aItemIds))); if (!$this->oField->GetHidden()) { @@ -115,14 +115,14 @@ EOF // Rendering table widget // - Vars - $sEmptyTableLabel = htmlentities(Dict::S(($this->oField->GetReadOnly()) ? 'Portal:Datatables:Language:EmptyTable' : 'UI:Message:EmptyList:UseAdd'), ENT_QUOTES, 'UTF-8'); - $sLabelGeneralCheckbox = htmlentities(Dict::S('Core:BulkExport:CheckAll') . ' / ' . Dict::S('Core:BulkExport:UncheckAll'), ENT_QUOTES, 'UTF-8'); + $sEmptyTableLabel = utils::EscapeHtml(Dict::S(($this->oField->GetReadOnly()) ? 'Portal:Datatables:Language:EmptyTable' : 'UI:Message:EmptyList:UseAdd')); + $sLabelGeneralCheckbox = utils::EscapeHtml(Dict::S('Core:BulkExport:CheckAll').' / '.Dict::S('Core:BulkExport:UncheckAll')); $sSelectionOptionHtml = ($this->oField->GetReadOnly()) ? 'false' : '{"style": "multi"}'; - $sSelectionInputGlobalHtml = ($this->oField->GetReadOnly()) ? '' : ''; - $sSelectionInputHtml = ($this->oField->GetReadOnly()) ? '' : ''; + $sSelectionInputGlobalHtml = ($this->oField->GetReadOnly()) ? '' : ''; + $sSelectionInputHtml = ($this->oField->GetReadOnly()) ? '' : ''; // - Output $oOutput->AddJs( -<<AddHtml(''); + $oOutput->AddHtml(''); } else { @@ -73,11 +73,10 @@ class ConsoleSimpleFieldRenderer extends FieldRenderer $oValue->AddSubBlock(InputUIBlockFactory::MakeForHidden("",$this->oField->GetCurrentValue(),$this->oField->GetGlobalId())); $oValue->AddSubBlock(new Html($this->oField->GetCurrentValue())); } - else - { - $oField = UIContentBlockUIBlockFactory::MakeStandard("",["field_input_zone", "field_input_datetime", "ibo-input-field-wrapper", "ibo-input-datetime-wrapper"]); + else { + $oField = UIContentBlockUIBlockFactory::MakeStandard("", ["field_input_zone", "field_input_datetime", "ibo-input-field-wrapper", "ibo-input-datetime-wrapper"]); $oValue->AddSubBlock($oField); - $oField->AddSubBlock(new Html('')); + $oField->AddSubBlock(new Html('')); $oField->AddSubBlock(new Html('')); } $oBlock->AddSubBlock($oValue); diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index eb9d32b2c..72de482b9 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -611,8 +611,7 @@ EOF $aData['nb_obj_total'] = $iNew + $iExisting + $iDisappeared; $aData['nb_replica_total'] = $aData['nb_obj_total'] + $iIgnored; if (strlen($oLastLog->Get('traces')) > 0) { - $aData['traces'] = '
Debug traces
'.htmlentities($oLastLog->Get('traces'), ENT_QUOTES,
-					'UTF-8').'
'; + $aData['traces'] = '
Debug traces
'.utils::EscapeHtml($oLastLog->Get('traces')).'
'; } else { $aData['traces'] = ''; } diff --git a/test/VerifyOQL.php b/test/VerifyOQL.php index 1b76d2527..b2ac5d9ef 100644 --- a/test/VerifyOQL.php +++ b/test/VerifyOQL.php @@ -73,9 +73,9 @@ function ShowExamples($oP, $sExpression) } //$aDisplayData[$sTopic][] = array( $aDisplayData[Dict::S('UI:RunQuery:QueryExamples')][] = array( - 'desc' => "
".htmlentities($sDescription, ENT_QUOTES, 'UTF-8')."
", - 'oql' => "
".htmlentities($sOql, ENT_QUOTES, 'UTF-8')."
", - 'go' => "
$sContext
\n", + 'desc' => "
".utils::EscapeHtml($sDescription)."
", + 'oql' => "
".utils::EscapeHtml($sOql)."
", + 'go' => "
$sContext
\n", ); } } @@ -147,8 +147,7 @@ try { $aArgs[$sParam] = $value; } - else - { + else { $aArgs[$sParam] = ''; } } @@ -158,7 +157,7 @@ try $oP->add("
\n"); $oP->add(Dict::S('UI:RunQuery:ExpressionToEvaluate')."
\n"); - $oP->add("\n"); + $oP->add("\n"); $oP->add_linked_script(utils::GetAbsoluteUrlAppRoot()."/js/jquery.hotkeys.js"); $oP->add_ready_script(<< 0) - { + if (strlen($sSuggestedWord) > 0) { $oP->p(''.Dict::Format('UI:RunQuery:Error', $e->GetIssue().' '.$sWrongWord).''); $sBefore = substr($sExpression, 0, $e->GetColumn()); $sAfter = substr($sExpression, $e->GetColumn() + strlen($sWrongWord)); $sFixedExpression = $sBefore.$sSuggestedWord.$sAfter; $sFixedExpressionHtml = $sBefore.''.$sSuggestedWord.''.$sAfter; $oP->p("Suggesting: $sFixedExpressionHtml"); - $oP->add(''); + $oP->add(''); } else {