Properly create DOMNodes with a text content (beware of XML entities inside the text)

SVN:trunk[3829]
This commit is contained in:
Denis Flaven
2015-11-25 16:52:49 +00:00
parent c9576c696a
commit d0a50adf32

View File

@@ -429,6 +429,7 @@ class ModelFactory
$oModuleNode->setAttribute('id', $oModule->GetId());
$oModuleNode->AppendChild($this->oDOMDocument->CreateElement('root_dir', $oModule->GetRootDir()));
$oModuleNode->AppendChild($this->oDOMDocument->CreateElement('label', $oModule->GetLabel()));
$this->oModules->AppendChild($oModuleNode);
foreach($aDataModels as $sXmlFile)
@@ -1995,6 +1996,22 @@ class MFDocument extends DOMDocument
}
return parent::saveXML();
}
/**
* Overload createElement to make sure (via new DOMText) that the XML entities are
* always properly escaped
* (non-PHPdoc)
* @see DOMDocument::createElement()
*/
function createElement($sName, $value = null, $namespaceURI = null)
{
$oElement = $this->importNode(new MFElement($sName, null, $namespaceURI));
if (!empty($value))
{
$oElement->appendChild(new DOMText($value));
}
return $oElement;
}
/**
* For debugging purposes
*/