summaryrefslogtreecommitdiffstats
path: root/lib/private/app
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-11-25 10:22:06 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-11-25 11:53:28 +0100
commit5ce34fbaf69538ad3338beebdfb015e94f8b6a3e (patch)
treed031454dc7f370a1f9c6eb60ee62d98f82535d7d /lib/private/app
parentd4f107d4dd11d11c52f419d2f33abc5dc4a93573 (diff)
downloadnextcloud-server-5ce34fbaf69538ad3338beebdfb015e94f8b6a3e.tar.gz
nextcloud-server-5ce34fbaf69538ad3338beebdfb015e94f8b6a3e.zip
handle invalid xml file
Diffstat (limited to 'lib/private/app')
-rw-r--r--lib/private/app/infoparser.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/private/app/infoparser.php b/lib/private/app/infoparser.php
index f7c3f8213a7..b4bdbea5c04 100644
--- a/lib/private/app/infoparser.php
+++ b/lib/private/app/infoparser.php
@@ -11,9 +11,17 @@
namespace OC\App;
use OCP\IURLGenerator;
-use SimpleXMLElement;
class InfoParser {
+ /**
+ * @var \OC\HTTPHelper
+ */
+ private $httpHelper;
+
+ /**
+ * @var IURLGenerator
+ */
+ private $urlGenerator;
/**
* @param \OC\HTTPHelper $httpHelper
@@ -25,15 +33,20 @@ class InfoParser {
}
/**
- * @param string $file
- * @return null|string
+ * @param string $file the xml file to be loaded
+ * @return null|array where null is an indicator for an error
*/
public function parse($file) {
if (!file_exists($file)) {
return null;
}
- $xml = simplexml_load_file($file);
+ $loadEntities = libxml_disable_entity_loader(false);
+ $xml = @simplexml_load_file($file);
+ libxml_disable_entity_loader($loadEntities);
+ if ($xml == false) {
+ return null;
+ }
$array = json_decode(json_encode((array)$xml), TRUE);
if (is_null($array)) {
return null;
@@ -56,15 +69,13 @@ class InfoParser {
$url = $this->urlGenerator->linkToDocs($url);
}
- $array["documentation"][$key] = $url;
-
+ $array['documentation'][$key] = $url;
}
}
if (array_key_exists('types', $array)) {
foreach ($array['types'] as $type => $v) {
unset($array['types'][$type]);
$array['types'][] = $type;
-
}
}