mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 00:58:48 +02:00
Internal: correctly quote XPath literals within GetNodeById
SVN:trunk[3049]
This commit is contained in:
@@ -2221,7 +2221,8 @@ class MFDocument extends DOMDocument
|
||||
public function GetNodeById($sXPath, $sId, $oContextNode = null)
|
||||
{
|
||||
$oXPath = new DOMXPath($this);
|
||||
$sXPath .= "[@id='$sId' and(not(@_alteration) or @_alteration!='removed')]";
|
||||
$sQuotedId = self::XPathQuote($sId);
|
||||
$sXPath .= "[@id=$sQuotedId and(not(@_alteration) or @_alteration!='removed')]";
|
||||
|
||||
if (is_null($oContextNode))
|
||||
{
|
||||
@@ -2232,4 +2233,18 @@ class MFDocument extends DOMDocument
|
||||
return $oXPath->query($sXPath, $oContextNode);
|
||||
}
|
||||
}
|
||||
|
||||
public static function XPathQuote($sValue)
|
||||
{
|
||||
if (strpos($sValue, '"') !== false)
|
||||
{
|
||||
$aParts = explode('"', $sValue);
|
||||
$sRet = 'concat("'.implode('", \'"\', "', $aParts).'")';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sRet = '"'.$sValue.'"';
|
||||
}
|
||||
return $sRet;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user