diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index 534b5ce2c2..d60b507e93 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -110,6 +110,15 @@ class RepairMimeTypes implements IRepairStep { } } + private function introduceImageTypes() { + $updatedMimetypes = array( + 'jp2' => 'image/jp2', + 'webp' => 'image/webp', + ); + + $this->updateMimetypes($updatedMimetypes); + } + private function introduceWindowsProgramTypes() { $updatedMimetypes = array( 'htaccess' => 'text/plain', @@ -130,6 +139,10 @@ class RepairMimeTypes implements IRepairStep { // NOTE TO DEVELOPERS: when adding new mime types, please make sure to // add a version comparison to avoid doing it every time + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.14', '<') && $this->introduceImageTypes()) { + $out->info('Fixed image mime types'); + } + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.13', '<') && $this->introduceWindowsProgramTypes()) { $out->info('Fixed windows program mime types'); } diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index 2b187a6ac8..09be65dd86 100644 --- a/resources/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -71,6 +71,7 @@ "iiq": ["image/x-dcraw"], "impress": ["text/impress"], "java": ["text/x-java-source"], + "jp2": ["image/jp2"], "jpeg": ["image/jpeg"], "jpg": ["image/jpeg"], "jps": ["image/jpeg"], @@ -170,6 +171,7 @@ "vsd": ["application/vnd.visio"], "wav": ["audio/wav"], "webm": ["video/webm"], + "webp": ["image/webp"], "woff": ["application/font-woff"], "wpd": ["application/vnd.wordperfect"], "wmv": ["video/x-ms-wmv"], diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index ef1412b2fd..f30bbdf7d1 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -106,6 +106,23 @@ class RepairMimeTypesTest extends \Test\TestCase { $this->checkEntries($fixedMimeTypes); } + /** + * Test renaming the additional image mime types + */ + public function testRenameImageTypes() { + $currentMimeTypes = [ + ['test.jp2', 'application/octet-stream'], + ['test.webp', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.jp2', 'image/jp2'], + ['test.webp', 'image/webp'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + /** * Test renaming the richdocuments additional office mime types */ @@ -163,8 +180,10 @@ class RepairMimeTypesTest extends \Test\TestCase { ['test.sr2', 'image/x-dcraw'], ['test.xrf', 'image/x-dcraw'], ['test.DNG', 'image/x-dcraw'], + ['test.jp2', 'image/jp2'], ['test.jps', 'image/jpeg'], ['test.MPO', 'image/jpeg'], + ['test.webp', 'image/webp'], ['test.conf', 'text/plain'], ['test.cnf', 'text/plain'], ['test.yaml', 'application/yaml'], @@ -215,8 +234,10 @@ class RepairMimeTypesTest extends \Test\TestCase { ['test.sr2', 'image/x-dcraw'], ['test.xrf', 'image/x-dcraw'], ['test.DNG', 'image/x-dcraw'], + ['test.jp2', 'image/jp2'], ['test.jps', 'image/jpeg'], ['test.MPO', 'image/jpeg'], + ['test.webp', 'image/webp'], ['test.conf', 'text/plain'], ['test.cnf', 'text/plain'], ['test.yaml', 'application/yaml'],