Skip to content

Commit

Permalink
Merge pull request #10264 from jitendrapurohit/CRM-20171
Browse files Browse the repository at this point in the history
CRM-20171: Use loadXML() instead of load() for reading xml files.
  • Loading branch information
colemanw authored May 4, 2017
2 parents 58bf7ae + f9857c5 commit bbf0d15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CRM/Case/Audit/AuditConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function loadConfig() {
$this->includeRules = array();

$doc = new DOMDocument();
if ($doc->load(dirname(__FILE__) . '/' . $this->filename)) {
$xmlString = file_get_contents(dirname(__FILE__) . '/' . $this->filename);
$load = $doc->loadXML($xmlString);
if ($load) {
$regions = $doc->getElementsByTagName("region");
foreach ($regions as $region) {
$regionName = $region->getAttribute("name");
Expand Down
4 changes: 3 additions & 1 deletion CRM/Case/XMLRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ public function retrieveFile($caseType) {
if ($fileName && file_exists($fileName)) {
// read xml file
$dom = new DomDocument();
$dom->load($fileName);
$xmlString = file_get_contents($fileName);
$dom->loadXML($xmlString);
$dom->documentURI = $fileName;
$dom->xinclude();
$fileXml = simplexml_import_dom($dom);
}
Expand Down
4 changes: 3 additions & 1 deletion CRM/Core/CodeGen/Util/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class CRM_Core_CodeGen_Util_Xml {
*/
public static function parse($file) {
$dom = new DomDocument();
$dom->load($file);
$xmlString = file_get_contents($file);
$dom->loadXML($xmlString);
$dom->documentURI = $file;
$dom->xinclude();
$xml = simplexml_import_dom($dom);
return $xml;
Expand Down
4 changes: 3 additions & 1 deletion CRM/Utils/Migrate/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function __construct() {
public function run($file) {
// read xml file
$dom = new DomDocument();
if (!$dom->load($file)) {
$xmlString = file_get_contents($file);
$load = $dom->loadXML($xmlString);
if (!$load) {
throw new CRM_Core_Exception("Failed to parse XML file \"$file\"");
}
$dom->xinclude();
Expand Down

0 comments on commit bbf0d15

Please sign in to comment.