}
public static function init() {
+ // prevent any XML processing from loading external entities
+ libxml_set_external_entity_loader(static function () {
+ return null;
+ });
+
// calculate the root directories
OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4));
libxml_use_internal_errors(true);
$loadEntities = libxml_disable_entity_loader(false);
- $xml = simplexml_load_file($appPath . '/appinfo/database.xml');
+ $xml = simplexml_load_string(file_get_contents($appPath . '/appinfo/database.xml'));
libxml_disable_entity_loader($loadEntities);
throw new \RuntimeException("No app with given id <$appId> known.");
}
+ libxml_set_external_entity_loader(static function ($public, $system, $context) {
+ if ($system === \OC::$SERVERROOT . '/resources/app-info.xsd'
+ || \OC::$SERVERROOT . '/resources/app-info-shipped.xsd') {
+ return $system;
+ }
+ return null;
+ });
+
$xml = new \DOMDocument();
$xml->load($appPath . '/appinfo/info.xml');
}
}
+ libxml_set_external_entity_loader(static function () {
+ return null;
+ });
+
return $errors;
}
use OCP\ICache;
use function libxml_disable_entity_loader;
-use function simplexml_load_file;
+use function simplexml_load_string;
class InfoParser {
/** @var \OCP\ICache|null */
libxml_use_internal_errors(true);
if ((PHP_VERSION_ID < 80000)) {
$loadEntities = libxml_disable_entity_loader(false);
- $xml = simplexml_load_file($file);
+ $xml = simplexml_load_string(file_get_contents($file));
libxml_disable_entity_loader($loadEntities);
} else {
- $xml = simplexml_load_file($file);
+ $xml = simplexml_load_string(file_get_contents($file));
}
if ($xml === false) {
*/
public function loadSchemaFromFile($file, Schema $schema) {
$loadEntities = libxml_disable_entity_loader(false);
- $xml = simplexml_load_file($file);
+ $xml = simplexml_load_string(file_get_contents($file));
libxml_disable_entity_loader($loadEntities);
foreach ($xml->children() as $child) {
/**
// Check if appinfo/info.xml has the same app ID as well
if ((PHP_VERSION_ID < 80000)) {
$loadEntities = libxml_disable_entity_loader(false);
- $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
+ $xml = simplexml_load_string(file_get_contents($extractDir . '/' . $folders[0] . '/appinfo/info.xml'));
libxml_disable_entity_loader($loadEntities);
} else {
- $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml');
+ $xml = simplexml_load_string(file_get_contents($extractDir . '/' . $folders[0] . '/appinfo/info.xml'));
}
if ((string)$xml->id !== $appId) {
throw new \Exception(