diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-04-26 01:22:49 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 01:22:49 -0300 |
commit | d4329f33556eaac6e863c2733e2e05964f3d0935 (patch) | |
tree | 2de5db28089ea4d51ef2034df2ad333084d49fd1 | |
parent | 215573fe3ceecd701079961b598fbae9871da07b (diff) | |
parent | 8ba67fbe1ec54dd961b8df9c0dda12efb5ca8ebb (diff) | |
download | nextcloud-server-d4329f33556eaac6e863c2733e2e05964f3d0935.tar.gz nextcloud-server-d4329f33556eaac6e863c2733e2e05964f3d0935.zip |
Merge pull request #4449 from stweil/mimetypes
Add mimetypes for jp2 and webp
-rw-r--r-- | lib/private/Repair/RepairMimeTypes.php | 13 | ||||
-rw-r--r-- | resources/config/mimetypemapping.dist.json | 2 | ||||
-rw-r--r-- | tests/lib/Repair/RepairMimeTypesTest.php | 21 |
3 files changed, 36 insertions, 0 deletions
diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index 534b5ce2c28..d60b507e932 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 2b187a6ac85..09be65dd86f 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 ef1412b2fd2..f30bbdf7d11 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -107,6 +107,23 @@ class RepairMimeTypesTest extends \Test\TestCase { } /** + * 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 */ public function testRenameWindowsProgramTypes() { @@ -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'], |