Skip to content

Commit be9b2e2

Browse files
committed
More libxml_disable_entity_loader
1 parent bd65e88 commit be9b2e2

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

workbench/bulkclient/BatchInfo.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ class BatchInfo {
5151
private $xml;
5252

5353
public function __construct($xml) {
54-
$this->xml = new SimpleXMLElement($xml);
54+
try {
55+
libxml_disable_entity_loader(true);
56+
$this->xml = new SimpleXMLElement(disallowDoctype($xml));
57+
} finally {
58+
libxml_disable_entity_loader(false);
59+
}
5560

5661
if ($this->getExceptionCode() != "") {
5762
throw new Exception($this->getExceptionCode() . ": " . $this->getExceptionMessage());

workbench/bulkclient/BulkApiClient.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,13 @@ public function getBatchInfo($jobId, $batchId) {
280280
public function getBatchInfos($jobId) {
281281
$batchInfos = array();
282282

283-
$batchInfoList = new SimpleXMLElement($this->get($this->url(array(self::JOB, $jobId, self::BATCH))));
283+
try {
284+
libxml_disable_entity_loader(true);
285+
$batchInfoList = new SimpleXMLElement(disallowDoctype($this->get($this->url(array(self::JOB, $jobId, self::BATCH)))));
286+
} finally {
287+
libxml_disable_entity_loader(false);
288+
}
289+
284290
foreach ($batchInfoList as $batchInfoListItem) {
285291
$batchInfos["$batchInfoListItem->id"] = new BatchInfo($batchInfoListItem->asXml());
286292
}

workbench/bulkclient/JobInfo.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ class JobInfo {
3939

4040
public function __construct($xml = null) {
4141
if ($xml != null) {
42-
$this->xml = new SimpleXMLElement($xml);
42+
try {
43+
libxml_disable_entity_loader(true);
44+
$this->xml = new SimpleXMLElement(disallowDoctype($xml));
45+
} finally {
46+
libxml_disable_entity_loader(false);
47+
}
4348
} else {
4449
$this->xml = new SimpleXMLElement("<jobInfo xmlns=\"http://www.force.com/2009/06/asyncapi/dataload\"/>");
4550

workbench/shared.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,12 @@ function in_arrayi($needle, $haystack) {
643643
*/
644644
function prettyPrintXml($xml, $htmlOutput=FALSE) {
645645
try {
646-
$xmlObj = new SimpleXMLElement($xml);
646+
libxml_disable_entity_loader(true);
647+
$xmlObj = new SimpleXMLElement(disallowDoctype($xml));
647648
} catch (Exception $e) {
648649
return $xml;
650+
} finally {
651+
libxml_disable_entity_loader(false);
649652
}
650653

651654
$xmlLines = explode("

0 commit comments

Comments
 (0)