N°8440 Allow icon file ids to contain quotes, by correctly escaping language literals (XPath or PHP)

This commit is contained in:
Romain Quetiez
2025-06-13 09:55:25 +02:00
parent 0a4f9e95c5
commit 2086052d60
3 changed files with 9 additions and 3 deletions

View File

@@ -2652,7 +2652,7 @@ EOF
if (is_null($sIconRelPath)) {
$sIconRelPath = "null";
} else {
$sIconRelPath = "'$sModuleRelDir/$sIconRelPath'";
$sIconRelPath = self::QuoteForPHP("$sModuleRelDir/$sIconRelPath");
}
// CSS classes representing the element (regular and alternative)
@@ -3300,7 +3300,8 @@ EOF;
$sFileId = $oFileRef->getAttribute('ref');
if ($sFileId !== '')
{
$oNodes = $this->oFactory->GetNodes("/itop_design/files/file[@id='$sFileId']");
$sQuotedFileId = self::QuoteForPHP($sFileId);
$oNodes = $this->oFactory->GetNodes("/itop_design/files/file[@id=$sQuotedFileId]");
if ($oNodes->length == 0)
{
throw new DOMFormatException('Could not find the file with ref '.$sFileId);

View File

@@ -2610,6 +2610,10 @@ class MFDocument extends \Combodo\iTop\DesignDocument
$oResult = $oXPath->query($sXPath, $oContextNode);
}
if ($oResult === false) {
throw new \Exception("Invalid XPath: $sXPath");
}
return $oResult;
}