diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2019-07-07 20:01:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-07 20:01:58 +0200 |
commit | 5a03189ce71490f5edac7d11905b21023bb8b04f (patch) | |
tree | 4813b97b5ee2ea4fd89a8836f53f2652229f5ebb /lib | |
parent | 1f4312fd9238928c91b9267d59212079f44b2ef3 (diff) | |
parent | ea2d75c2b446ee8548ad19c17460a9a187c92e4a (diff) | |
download | nextcloud-server-5a03189ce71490f5edac7d11905b21023bb8b04f.tar.gz nextcloud-server-5a03189ce71490f5edac7d11905b21023bb8b04f.zip |
Mimetype list integrity check should not fail if it's changed (#15810)
Mimetype list integrity check should not fail if it's changed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 | ||||
-rw-r--r-- | lib/private/Files/Type/Detection.php | 6 | ||||
-rw-r--r-- | lib/private/IntegrityCheck/Checker.php | 17 | ||||
-rw-r--r-- | lib/private/Server.php | 3 |
5 files changed, 26 insertions, 2 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index f608ce0b77c..2a5d410acec 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -675,6 +675,7 @@ return array( 'OC\\Core\\Command\\Log\\Manage' => $baseDir . '/core/Command/Log/Manage.php', 'OC\\Core\\Command\\Maintenance\\DataFingerprint' => $baseDir . '/core/Command/Maintenance/DataFingerprint.php', 'OC\\Core\\Command\\Maintenance\\Install' => $baseDir . '/core/Command/Maintenance/Install.php', + 'OC\\Core\\Command\\Maintenance\\Mimetype\\GenerateMimetypeFileBuilder' => $baseDir . '/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php', 'OC\\Core\\Command\\Maintenance\\Mimetype\\UpdateDB' => $baseDir . '/core/Command/Maintenance/Mimetype/UpdateDB.php', 'OC\\Core\\Command\\Maintenance\\Mimetype\\UpdateJS' => $baseDir . '/core/Command/Maintenance/Mimetype/UpdateJS.php', 'OC\\Core\\Command\\Maintenance\\Mode' => $baseDir . '/core/Command/Maintenance/Mode.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index fc4fc585e60..807b498043b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -709,6 +709,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Log\\Manage' => __DIR__ . '/../../..' . '/core/Command/Log/Manage.php', 'OC\\Core\\Command\\Maintenance\\DataFingerprint' => __DIR__ . '/../../..' . '/core/Command/Maintenance/DataFingerprint.php', 'OC\\Core\\Command\\Maintenance\\Install' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Install.php', + 'OC\\Core\\Command\\Maintenance\\Mimetype\\GenerateMimetypeFileBuilder' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Mimetype/GenerateMimetypeFileBuilder.php', 'OC\\Core\\Command\\Maintenance\\Mimetype\\UpdateDB' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Mimetype/UpdateDB.php', 'OC\\Core\\Command\\Maintenance\\Mimetype\\UpdateJS' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Mimetype/UpdateJS.php', 'OC\\Core\\Command\\Maintenance\\Mode' => __DIR__ . '/../../..' . '/core/Command/Maintenance/Mode.php', diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 32075627632..9bbbd0e07c7 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -133,6 +133,12 @@ class Detection implements IMimeTypeDetector { return $this->mimeTypeAlias; } + public function getOnlyDefaultAliases() { + $this->loadMappings(); + $this->mimeTypeAlias = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypealiases.dist.json'), true); + return $this->mimeTypeAlias; + } + /** * Add mimetype mappings if they are not yet present */ diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index 0a8876381f4..bc46c1d75ae 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OC\IntegrityCheck; +use OC\Core\Command\Maintenance\Mimetype\GenerateMimetypeFileBuilder; use OC\IntegrityCheck\Exceptions\InvalidSignatureException; use OC\IntegrityCheck\Helpers\AppLocator; use OC\IntegrityCheck\Helpers\EnvironmentHelper; @@ -34,6 +35,7 @@ use OC\IntegrityCheck\Helpers\FileAccessHelper; use OC\IntegrityCheck\Iterator\ExcludeFileByNameFilterIterator; use OC\IntegrityCheck\Iterator\ExcludeFoldersByPathFilterIterator; use OCP\App\IAppManager; +use OCP\Files\IMimeTypeDetector; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; @@ -67,6 +69,8 @@ class Checker { private $appManager; /** @var ITempManager */ private $tempManager; + /** @var IMimeTypeDetector */ + private $mimeTypeDetector; /** * @param EnvironmentHelper $environmentHelper @@ -76,6 +80,7 @@ class Checker { * @param ICacheFactory $cacheFactory * @param IAppManager $appManager * @param ITempManager $tempManager + * @param IMimeTypeDetector $mimeTypeDetector */ public function __construct(EnvironmentHelper $environmentHelper, FileAccessHelper $fileAccessHelper, @@ -83,7 +88,8 @@ class Checker { IConfig $config = null, ICacheFactory $cacheFactory, IAppManager $appManager = null, - ITempManager $tempManager) { + ITempManager $tempManager, + IMimeTypeDetector $mimeTypeDetector) { $this->environmentHelper = $environmentHelper; $this->fileAccessHelper = $fileAccessHelper; $this->appLocator = $appLocator; @@ -91,6 +97,7 @@ class Checker { $this->cache = $cacheFactory->createDistributed(self::CACHE_KEY); $this->appManager = $appManager; $this->tempManager = $tempManager; + $this->mimeTypeDetector = $mimeTypeDetector; } /** @@ -193,6 +200,14 @@ class Checker { continue; } } + if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') { + $oldMimetypeList = new GenerateMimetypeFileBuilder(); + $newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases()); + if($newFile === file_get_contents($filename)) { + $hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases())); + continue; + } + } $hashes[$relativeFileName] = hash_file('sha512', $filename); } diff --git a/lib/private/Server.php b/lib/private/Server.php index ac0a4ab8a41..6a2d8106fb6 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -790,7 +790,8 @@ class Server extends ServerContainer implements IServerContainer { $config, $c->getMemCacheFactory(), $appManager, - $c->getTempManager() + $c->getTempManager(), + $c->getMimeTypeDetector() ); }); $this->registerService(\OCP\IRequest::class, function ($c) { |