Commit 3d2116df authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #15386 from oparoz/yaml-cnf-mediatype

Introducing media types for yml, yaml, cnf, conf
parents a2087f30 70ec74e8
......@@ -2,17 +2,17 @@
/**
* @author Arthur Schiwon <blizzz@owncloud.com>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Bjrn Schiele <schiessle@owncloud.com>
* @author Christopher Schpers <kondou@ts.unde.re>
* @author Björn Schießle <schiessle@owncloud.com>
* @author Christopher Schäpers <kondou@ts.unde.re>
* @author Fabian Henze <flyser42@gmx.de>
* @author Felix Moeller <mail@felixmoeller.de>
* @author Franois Kubler <francois@kubler.org>
* @author François Kubler <francois@kubler.org>
* @author Frank Karlitschek <frank@owncloud.org>
* @author Georg Ehrke <georg@owncloud.com>
* @author Jakob Sack <mail@jakobsack.de>
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jrn Friedrich Dreyer <jfd@butonic.de>
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com>
* @author Michael Gapczynski <GapczynskiM@gmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
......@@ -22,8 +22,8 @@
* @author Robin Appelman <icewind@owncloud.com>
* @author Robin McCorkell <rmccorkell@karoshi.org.uk>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Simon Knnecke <simonkoennecke@gmail.com>
* @author Thomas Mller <thomas.mueller@tmit.eu>
* @author Simon Könnecke <simonkoennecke@gmail.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Thomas Tanghus <thomas@tanghus.net>
* @author Valerio Ponte <valerio.ponte@gmail.com>
* @author Vincent Petry <pvince81@owncloud.com>
......@@ -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',
......
......@@ -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),
);
......@@ -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'));
}
}
}
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment