@ -26,20 +26,8 @@
namespace OC\App;
use OCP\IURLGenerator;
class InfoParser {
/** @var IURLGenerator */
private $urlGenerator;
/**
* @param IURLGenerator $urlGenerator
*/
public function __construct(IURLGenerator $urlGenerator) {
$this->urlGenerator = $urlGenerator;
}
/**
* @param string $file the xml file to be loaded
* @return null|array where null is an indicator for an error
@ -52,15 +40,18 @@ class InfoParser {
libxml_use_internal_errors(true);
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
libxml_disable_entity_loader($loadEntities);
if ($xml == false) {
if ($xml === false) {
libxml_clear_errors();
return null;
}
$array = $this->xmlToArray($xml);
if (is_null($array)) {
return null;
}
if (!array_key_exists('info', $array)) {
$array['info'] = [];
}
@ -98,17 +89,6 @@ class InfoParser {
$array['two-factor-providers'] = [];
}
if (array_key_exists('documentation', $array) & & is_array($array['documentation'])) {
foreach ($array['documentation'] as $key => $url) {
// If it is not an absolute URL we assume it is a key
// i.e. admin-ldap will get converted to go.php?to=admin-ldap
if (!$this->isHTTPURL($url)) {
$url = $this->urlGenerator->linkToDocs($url);
}
$array['documentation'][$key] = $url;
}
}
if (array_key_exists('types', $array)) {
if (is_array($array['types'])) {
foreach ($array['types'] as $type => $v) {
@ -193,8 +173,4 @@ class InfoParser {
return $array;
}
private function isHTTPURL($url) {
return stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0;
}
}