Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable25] fix(apps): Fix loading info.xml file #39493

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
// slash which is required by URL generation.
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
substr($_SERVER['REQUEST_URI'], -1) !== '/') {
header('Location: '.\OC::$WEBROOT.'/');

Check failure on line 205 in lib/base.php

View workflow job for this annotation

GitHub Actions / Psalm

Detected tainted header (see https://psalm.dev/256)

Check failure on line 205 in lib/base.php

View workflow job for this annotation

GitHub Actions / Psalm

Detected tainted header (see https://psalm.dev/256)
exit();
}
}
Expand Down Expand Up @@ -574,6 +574,11 @@
}

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));

Expand Down
6 changes: 3 additions & 3 deletions lib/private/App/InfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

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 */
Expand Down Expand Up @@ -63,10 +63,10 @@
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));

Check failure

Code scanning / Psalm

TaintedFile Error

Detected tainted file handling
libxml_disable_entity_loader($loadEntities);
} else {
$xml = simplexml_load_file($file);
$xml = simplexml_load_string(file_get_contents($file));

Check failure

Code scanning / Psalm

TaintedFile Error

Detected tainted file handling
}

if ($xml === false) {
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ public function downloadApp($appId, $allowUnstable = false) {
// 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(
Expand Down
Loading