diff --git a/lib/private/helper.php b/lib/private/helper.php index c5fcd27f2b..cb95dd49be 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -2,17 +2,17 @@ /** * @author Arthur Schiwon * @author Bart Visscher - * @author Björn Schießle - * @author Christopher Schäpers + * @author Björn Schießle + * @author Christopher Schäpers * @author Fabian Henze * @author Felix Moeller - * @author François Kubler + * @author François Kubler * @author Frank Karlitschek * @author Georg Ehrke * @author Jakob Sack * @author Jan-Christoph Borchardt * @author Joas Schilling - * @author Jörn Friedrich Dreyer + * @author Jörn Friedrich Dreyer * @author Lukas Reschke * @author Michael Gapczynski * @author Morris Jobke @@ -22,8 +22,8 @@ * @author Robin Appelman * @author Robin McCorkell * @author Roeland Jago Douma - * @author Simon Könnecke - * @author Thomas Müller + * @author Simon Könnecke + * @author Thomas Müller * @author Thomas Tanghus * @author Valerio Ponte * @author Vincent Petry @@ -75,6 +75,7 @@ class OC_Helper { 'application/x-perl' => 'text/code', 'application/x-php' => 'text/code', 'text/x-shellscript' => 'text/code', + 'application/yaml' => 'text/code', 'application/xml' => 'text/html', 'text/css' => 'text/code', 'application/x-tex' => 'text', diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php index c065a8b84f..427a152f05 100644 --- a/lib/private/mimetypes.list.php +++ b/lib/private/mimetypes.list.php @@ -53,6 +53,8 @@ return array( 'cbz' => array('application/x-cbr', null), 'cc' => array('text/x-c', null), 'cdr' => array('application/coreldraw', null), + 'cnf' => array('text/plain', null), + 'conf' => array('text/plain', null), 'cpp' => array('text/x-c++src', null), 'cr2' => array('image/x-dcraw', null), 'css' => array('text/css', null), @@ -183,5 +185,7 @@ return array( 'xltx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.template', null), 'xml' => array('application/xml', 'text/plain'), 'xrf' => array('image/x-dcraw', null), + 'yaml' => array('application/yaml', 'text/plain'), + 'yml' => array('application/yaml', 'text/plain'), 'zip' => array('application/zip', null), ); diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php index 3d39507b99..1b36894eed 100644 --- a/lib/repair/repairmimetypes.php +++ b/lib/repair/repairmimetypes.php @@ -218,6 +218,24 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { self::updateMimetypes($updatedMimetypes); } + private function introduceConfMimeType() { + $updatedMimetypes = array( + 'conf' => 'text/plain', + 'cnf' => 'text/plain', + ); + + self::updateMimetypes($updatedMimetypes); + } + + private function introduceYamlMimeType() { + $updatedMimetypes = array( + 'yaml' => 'application/yaml', + 'yml' => 'application/yaml', + ); + + self::updateMimetypes($updatedMimetypes); + } + /** * Fix mime types */ @@ -245,5 +263,13 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { if ($this->introduce3dImagesMimeType()) { $this->emit('\OC\Repair', 'info', array('Fixed 3D images mime types')); } + + if ($this->introduceConfMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed Conf/cnf mime types')); + } + + if ($this->introduceYamlMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed Yaml/Yml mime types')); + } } } diff --git a/tests/lib/repair/repairmimetypes.php b/tests/lib/repair/repairmimetypes.php index efae25f7e7..40ffc14612 100644 --- a/tests/lib/repair/repairmimetypes.php +++ b/tests/lib/repair/repairmimetypes.php @@ -221,15 +221,52 @@ class RepairMimeTypes extends \Test\TestCase { $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); } + /** + * Test renaming the 3D image media type + */ public function testRename3dImagesMimeType() { $currentMimeTypes = [ - ['test.eps', 'application/octet-stream'], - ['test.ps', 'application/octet-stream'], + ['test.jps', 'application/octet-stream'], + ['test.mpo', 'application/octet-stream'], ]; $fixedMimeTypes = [ - ['test.eps', 'application/postscript'], - ['test.ps', 'application/postscript'], + ['test.jps', 'image/jpeg'], + ['test.mpo', 'image/jpeg'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** + * Test renaming the conf/cnf media type + */ + public function testRenameConfMimeType() { + $currentMimeTypes = [ + ['test.conf', 'application/octet-stream'], + ['test.cnf', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.conf', 'text/plain'], + ['test.cnf', 'text/plain'], + ]; + + $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); + } + + /** + * Test renaming the yaml media type + */ + public function testRenameYamlMimeType() { + $currentMimeTypes = [ + ['test.yaml', 'application/octet-stream'], + ['test.yml', 'application/octet-stream'], + ]; + + $fixedMimeTypes = [ + ['test.yaml', 'application/yaml'], + ['test.yml', 'application/yaml'], ]; $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes); @@ -348,6 +385,10 @@ class RepairMimeTypes extends \Test\TestCase { ['test.DNG', 'image/x-dcraw'], ['test.jps', 'image/jpeg'], ['test.MPO', 'image/jpeg'], + ['test.conf', 'text/plain'], + ['test.cnf', 'text/plain'], + ['test.yaml', 'application/yaml'], + ['test.yml', 'application/yaml'], ]; $fixedMimeTypes = [ @@ -383,6 +424,10 @@ class RepairMimeTypes extends \Test\TestCase { ['test.DNG', 'image/x-dcraw'], ['test.jps', 'image/jpeg'], ['test.MPO', 'image/jpeg'], + ['test.conf', 'text/plain'], + ['test.cnf', 'text/plain'], + ['test.yaml', 'application/yaml'], + ['test.yml', 'application/yaml'], ]; $this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);