diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-02 17:50:34 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-02 17:50:34 +0200 |
commit | ff89824135298aa072c56f5a811f453df7ac3fe4 (patch) | |
tree | 43fa2941d995a6175c4918324cd0e91c775bf84f | |
parent | fee8486b7f50422958909abe9fa1305039ecbbab (diff) | |
parent | c80dd82fe4c197cb09344a2ce25f790cd597b792 (diff) | |
download | nextcloud-server-ff89824135298aa072c56f5a811f453df7ac3fe4.tar.gz nextcloud-server-ff89824135298aa072c56f5a811f453df7ac3fe4.zip |
Merge pull request #19272 from owncloud/mimetypes-enhanced
Introduce a few new mimetypes for code, fix recursive mimetype aliases
-rw-r--r-- | core/js/mimetype.js | 2 | ||||
-rw-r--r-- | core/js/mimetypelist.js | 57 | ||||
-rw-r--r-- | lib/private/files/type/detection.php | 2 | ||||
-rw-r--r-- | lib/repair/repairmimetypes.php | 52 | ||||
-rw-r--r-- | resources/config/mimetypealiases.dist.json | 29 | ||||
-rw-r--r-- | resources/config/mimetypemapping.dist.json | 5 | ||||
-rw-r--r-- | tests/lib/repair/repairmimetypes.php | 72 | ||||
-rw-r--r-- | version.php | 2 |
8 files changed, 186 insertions, 35 deletions
diff --git a/core/js/mimetype.js b/core/js/mimetype.js index d22b0a2378a..b0de8eb8411 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -70,7 +70,7 @@ OC.MimeType = { return undefined; } - if (mimeType in OC.MimeTypeList.aliases) { + while (mimeType in OC.MimeTypeList.aliases) { mimeType = OC.MimeTypeList.aliases[mimeType]; } if (mimeType in OC.MimeType._mimeTypeIcons) { diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index af2ad73c51b..43f01273f55 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -9,23 +9,26 @@ OC.MimeTypeList={ aliases: { "application/coreldraw": "image", - "application/font-sfnt": "font", - "application/font-woff": "font", - "application/illustrator": "image/vector", + "application/epub+zip": "text", + "application/font-sfnt": "image", + "application/font-woff": "image", + "application/illustrator": "image", + "application/javascript": "text/code", "application/json": "text/code", - "application/msaccess": "database", + "application/msaccess": "file", "application/msexcel": "x-office/spreadsheet", "application/mspowerpoint": "x-office/presentation", "application/msword": "x-office/document", "application/octet-stream": "file", - "application/postscript": "image/vector", + "application/postscript": "image", + "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", "application/vnd.ms-excel": "x-office/spreadsheet", "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", - "application/vnd.ms-fontobject": "font", + "application/vnd.ms-fontobject": "image", "application/vnd.ms-powerpoint": "x-office/presentation", "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", @@ -49,10 +52,11 @@ OC.MimeTypeList={ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", "application/x-7z-compressed": "package/x-generic", + "application/x-cbr": "text", "application/x-compressed": "package/x-generic", "application/x-dcraw": "image", "application/x-deb": "package/x-generic", - "application/x-font": "font", + "application/x-font": "image", "application/x-gimp": "image", "application/x-gzip": "package/x-generic", "application/x-perl": "text/code", @@ -64,33 +68,40 @@ OC.MimeTypeList={ "application/xml": "text/html", "application/yaml": "text/code", "application/zip": "package/x-generic", + "database": "file", "httpd/unix-directory": "dir", - "image/svg+xml": "image/vector", "text/css": "text/code", "text/csv": "x-office/spreadsheet", - "text/x-shellscript": "text/code" + "text/html": "text/code", + "text/x-c": "text/code", + "text/x-c++src": "text/code", + "text/x-h": "text/code", + "text/x-java-source": "text/code", + "text/x-python": "text/code", + "text/x-shellscript": "text/code", + "web": "text/code" }, files: [ - "application-pdf", - "application", - "audio", - "file", + "video", "folder-drag-accept", - "folder-external", - "folder-public", - "folder-shared", "folder-starred", - "folder", - "image", + "folder-public", "package-x-generic", - "text-calendar", - "text-code", - "text-vcard", "text", - "video", + "folder-external", + "text-vcard", + "application", + "text-code", + "x-office-spreadsheet", + "application-pdf", + "folder", "x-office-document", + "text-calendar", "x-office-presentation", - "x-office-spreadsheet" + "file", + "folder-shared", + "image", + "audio" ], themes: [] }; diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index 0c647ab44c6..dc8aff2f30c 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -269,7 +269,7 @@ class Detection implements IMimeTypeDetector { public function mimeTypeIcon($mimetype) { $this->loadAliases(); - if (isset($this->mimeTypeAlias[$mimetype])) { + while (isset($this->mimeTypeAlias[$mimetype])) { $mimetype = $this->mimeTypeAlias[$mimetype]; } if (isset($this->mimetypeIcons[$mimetype])) { diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php index db11f526ad6..b9cd42f3136 100644 --- a/lib/repair/repairmimetypes.php +++ b/lib/repair/repairmimetypes.php @@ -250,6 +250,39 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { self::updateMimetypes($updatedMimetypes); } + private function introduceJavaMimeType() { + $updatedMimetypes = array( + 'class' => 'application/java', + 'java' => 'text/x-java-source', + ); + + self::updateMimetypes($updatedMimetypes); + } + + private function introduceHppMimeType() { + $updatedMimetypes = array( + 'hpp' => 'text/x-h', + ); + + self::updateMimetypes($updatedMimetypes); + } + + private function introduceRssMimeType() { + $updatedMimetypes = array( + 'rss' => 'application/rss+xml', + ); + + self::updateMimetypes($updatedMimetypes); + } + + private function introduceRtfMimeType() { + $updatedMimetypes = array( + 'rtf' => 'text/rtf', + ); + + self::updateMimetypes($updatedMimetypes); + } + /** * Fix mime types */ @@ -294,5 +327,24 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { $this->emit('\OC\Repair', 'info', array('Fixed Yaml/Yml mime types')); } } + + // Mimetype updates from #19272 + if (version_compare($ocVersionFromBeforeUpdate, '8.2.0.8', '<')) { + if ($this->introduceJavaMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed java/class mime types')); + } + + if ($this->introduceHppMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed hpp mime type')); + } + + if ($this->introduceRssMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed rss mime type')); + } + + if ($this->introduceRtfMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed rtf mime type')); + } + } } } diff --git a/resources/config/mimetypealiases.dist.json b/resources/config/mimetypealiases.dist.json index 3d6c5edc132..ed471f228e2 100644 --- a/resources/config/mimetypealiases.dist.json +++ b/resources/config/mimetypealiases.dist.json @@ -9,23 +9,26 @@ "application/coreldraw": "image", - "application/font-sfnt": "font", - "application/font-woff": "font", - "application/illustrator": "image/vector", + "application/epub+zip": "text", + "application/font-sfnt": "image", + "application/font-woff": "image", + "application/illustrator": "image", + "application/javascript": "text/code", "application/json": "text/code", - "application/msaccess": "database", + "application/msaccess": "file", "application/msexcel": "x-office/spreadsheet", "application/mspowerpoint": "x-office/presentation", "application/msword": "x-office/document", "application/octet-stream": "file", - "application/postscript": "image/vector", + "application/postscript": "image", + "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", "application/vnd.ms-excel": "x-office/spreadsheet", "application/vnd.ms-excel.addin.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.binary.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.sheet.macroEnabled.12": "x-office/spreadsheet", "application/vnd.ms-excel.template.macroEnabled.12": "x-office/spreadsheet", - "application/vnd.ms-fontobject": "font", + "application/vnd.ms-fontobject": "image", "application/vnd.ms-powerpoint": "x-office/presentation", "application/vnd.ms-powerpoint.addin.macroEnabled.12": "x-office/presentation", "application/vnd.ms-powerpoint.presentation.macroEnabled.12": "x-office/presentation", @@ -49,10 +52,11 @@ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document", "application/x-7z-compressed": "package/x-generic", + "application/x-cbr": "text", "application/x-compressed": "package/x-generic", "application/x-dcraw": "image", "application/x-deb": "package/x-generic", - "application/x-font": "font", + "application/x-font": "image", "application/x-gimp": "image", "application/x-gzip": "package/x-generic", "application/x-perl": "text/code", @@ -64,10 +68,17 @@ "application/xml": "text/html", "application/yaml": "text/code", "application/zip": "package/x-generic", + "database": "file", "httpd/unix-directory": "dir", - "image/svg+xml": "image/vector", "text/css": "text/code", "text/csv": "x-office/spreadsheet", - "text/x-shellscript": "text/code" + "text/html": "text/code", + "text/x-c": "text/code", + "text/x-c++src": "text/code", + "text/x-h": "text/code", + "text/x-java-source": "text/code", + "text/x-python": "text/code", + "text/x-shellscript": "text/code", + "web": "text/code" } diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index 79b0ca65240..e26ec7038b1 100644 --- a/resources/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -27,6 +27,7 @@ "cbz": ["application/x-cbr"], "cc": ["text/x-c"], "cdr": ["application/coreldraw"], + "class": ["application/java"], "cnf": ["text/plain"], "conf": ["text/plain"], "cpp": ["text/x-c++src"], @@ -57,12 +58,14 @@ "gzip": ["application/x-gzip"], "h": ["text/x-h"], "hh": ["text/x-h"], + "hpp": ["text/x-h"], "html": ["text/html", "text/plain"], "htm": ["text/html", "text/plain"], "ical": ["text/calendar"], "ics": ["text/calendar"], "iiq": ["image/x-dcraw"], "impress": ["text/impress"], + "java": ["text/x-java-source"], "jpeg": ["image/jpeg"], "jpg": ["image/jpeg"], "jps": ["image/jpeg"], @@ -130,6 +133,8 @@ "raf": ["image/x-dcraw"], "rar": ["application/x-rar-compressed"], "reveal": ["text/reveal"], + "rss": ["application/rss+xml"], + "rtf": ["text/rtf"], "rw2": ["image/x-dcraw"], "sgf": ["application/sgf"], "sh-lib": ["text/x-shellscript"], diff --git a/tests/lib/repair/repairmimetypes.php b/tests/lib/repair/repairmimetypes.php index 3c100b808cf..0288a476ede 100644 --- a/tests/lib/repair/repairmimetypes.php +++ b/tests/lib/repair/repairmimetypes.php @@ -283,6 +283,68 @@ class RepairMimeTypes extends \Test\TestCase { } /** + * Test renaming the java mime types + */ + public function testRenameJavaMimeType() { + $currentMimeTypes = [ + ['test.java', 'application/octet-stream'], + ['test.class', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.java', 'text/x-java-source'], + ['test.class', 'application/java'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** + * Test renaming the hpp mime type + */ + public function testRenameHppMimeType() { + $currentMimeTypes = [ + ['test.hpp', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.hpp', 'text/x-h'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** + * Test renaming the rss mime type + */ + public function testRenameRssMimeType() { + $currentMimeTypes = [ + ['test.rss', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.rss', 'application/rss+xml'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** + * Test renaming the hpp mime type + */ + public function testRenameRtfMimeType() { + $currentMimeTypes = [ + ['test.rtf', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.rtf', 'text/rtf'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** * Test renaming and splitting old office mime types when * new ones already exist */ @@ -399,6 +461,11 @@ class RepairMimeTypes extends \Test\TestCase { ['test.cnf', 'text/plain'], ['test.yaml', 'application/yaml'], ['test.yml', 'application/yaml'], + ['test.java', 'text/x-java-source'], + ['test.class', 'application/java'], + ['test.hpp', 'text/x-h'], + ['test.rss', 'application/rss+xml'], + ['test.rtf', 'text/rtf'], ]; $fixedMimeTypes = [ @@ -438,6 +505,11 @@ class RepairMimeTypes extends \Test\TestCase { ['test.cnf', 'text/plain'], ['test.yaml', 'application/yaml'], ['test.yml', 'application/yaml'], + ['test.java', 'text/x-java-source'], + ['test.class', 'application/java'], + ['test.hpp', 'text/x-h'], + ['test.rss', 'application/rss+xml'], + ['test.rtf', 'text/rtf'], ]; $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); diff --git a/version.php b/version.php index 925e897d1ab..7ba6c3d93bc 100644 --- a/version.php +++ b/version.php @@ -23,7 +23,7 @@ // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = array(8, 2, 0, 7); +$OC_Version = array(8, 2, 0, 8); // The human readable string $OC_VersionString = '8.2 beta1'; |