Commit 5ce34fba authored by Thomas Müller's avatar Thomas Müller
Browse files

handle invalid xml file

parent d4f107d4
......@@ -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);
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) {
$array['types'][] = $type;
<?xml version="1.0"?>
<name>Server-side Encryption</name>
This application encrypts all files accessed by ownCloud at rest, wherever they are stored. As an example, with this application enabled, external cloud based Amazon S3 storage will be encrypted, protecting this data on storage outside of the control of the Admin. When this application is enabled for the first time, all files are encrypted as users log in and are prompted for their password. The recommended recovery key option enables recovery of files in case the key is lost.
Note that this app encrypts all files that are touched by ownCloud, so external storage providers and applications such as SharePoint will see new files encrypted when they are accessed. Encryption is based on AES 128 or 256 bit keys. More information is available in the Encryption documentation
<author>Sam Tuke, Bjoern Schiessle, Florin Peter</author>
......@@ -45,4 +45,9 @@ class InfoParser extends \PHPUnit_Framework_TestCase {
$this->assertEquals($expectedData, $data);
public function testParsingInvalidXml() {
$data = $this->parser->parse(OC::$SERVERROOT.'/tests/data/app/invalid-info.xml');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment