Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions core/js/mimetypelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ OC.MimeTypeList={
"application/gpx+xml": "location",
"application/gzip": "package/x-generic",
"application/illustrator": "image",
"application/internet-shortcut": "link",
"application/javascript": "text/code",
"application/json": "text/code",
"application/km": "mindmap",
"application/msaccess": "file",
"application/msexcel": "x-office/spreadsheet",
"application/msonenote": "x-office/document",
Expand All @@ -27,21 +29,21 @@ OC.MimeTypeList={
"application/rss+xml": "application/xml",
"application/vnd.android.package-archive": "package/x-generic",
"application/vnd.excalidraw+json": "whiteboard",
"application/vnd.lotus-wordpro": "x-office/document",
"application/vnd.garmin.tcx+xml": "location",
"application/vnd.google-earth.kml+xml": "location",
"application/vnd.google-earth.kmz": "location",
"application/vnd.ms-excel": "x-office/spreadsheet",
"application/vnd.lotus-wordpro": "x-office/document",
"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-excel": "x-office/spreadsheet",
"application/vnd.ms-fontobject": "font",
"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",
"application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "x-office/presentation",
"application/vnd.ms-powerpoint.template.macroEnabled.12": "x-office/presentation",
"application/vnd.ms-powerpoint": "x-office/presentation",
"application/vnd.ms-visio.drawing.macroEnabled.12": "application/vnd.visio",
"application/vnd.ms-visio.drawing": "application/vnd.visio",
"application/vnd.ms-visio.stencil.macroEnabled.12": "application/vnd.visio",
Expand All @@ -50,29 +52,32 @@ OC.MimeTypeList={
"application/vnd.ms-visio.template": "application/vnd.visio",
"application/vnd.ms-word.document.macroEnabled.12": "x-office/document",
"application/vnd.ms-word.template.macroEnabled.12": "x-office/document",
"application/vnd.oasis.opendocument.presentation": "x-office/presentation",
"application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing",
"application/vnd.oasis.opendocument.graphics-template": "x-office/drawing",
"application/vnd.oasis.opendocument.graphics": "x-office/drawing",
"application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation",
"application/vnd.oasis.opendocument.presentation-template": "x-office/presentation",
"application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet",
"application/vnd.oasis.opendocument.presentation": "x-office/presentation",
"application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet",
"application/vnd.oasis.opendocument.spreadsheet-template": "x-office/spreadsheet",
"application/vnd.oasis.opendocument.text": "x-office/document",
"application/vnd.oasis.opendocument.spreadsheet": "x-office/spreadsheet",
"application/vnd.oasis.opendocument.text-flat-xml": "x-office/document",
"application/vnd.oasis.opendocument.text-master": "x-office/document",
"application/vnd.oasis.opendocument.text-template": "x-office/document",
"application/vnd.oasis.opendocument.graphics": "x-office/drawing",
"application/vnd.oasis.opendocument.graphics-template": "x-office/drawing",
"application/vnd.oasis.opendocument.text-web": "x-office/document",
"application/vnd.oasis.opendocument.text-flat-xml": "x-office/document",
"application/vnd.oasis.opendocument.spreadsheet-flat-xml": "x-office/spreadsheet",
"application/vnd.oasis.opendocument.graphics-flat-xml": "x-office/drawing",
"application/vnd.oasis.opendocument.presentation-flat-xml": "x-office/presentation",
"application/vnd.oasis.opendocument.text": "x-office/document",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "x-office/presentation",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow": "x-office/presentation",
"application/vnd.openxmlformats-officedocument.presentationml.template": "x-office/presentation",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "x-office/spreadsheet",
"application/vnd.openxmlformats-officedocument.spreadsheetml.template": "x-office/spreadsheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "x-office/document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template": "x-office/document",
"application/vnd.visio": "x-office/document",
"application/vnd.wordperfect": "x-office/document",
"application/vnd.xmind.workbook": "mindmap",
"application/x-7z-compressed": "package/x-generic",
"application/x-bzip2": "package/x-generic",
"application/x-cbr": "text",
Expand All @@ -81,6 +86,7 @@ OC.MimeTypeList={
"application/x-deb": "package/x-generic",
"application/x-fictionbook+xml": "text",
"application/x-font": "font",
"application/x-freemind": "mindmap",
"application/x-gimp": "image",
"application/x-gzip": "application/gzip",
"application/x-iwork-keynote-sffkey": "x-office/presentation",
Expand All @@ -96,8 +102,11 @@ OC.MimeTypeList={
"application/xml": "text/html",
"application/yaml": "text/code",
"application/zip": "package/x-generic",
"application/zstd": "package/x-generic",
"database": "file",
"httpd/unix-directory": "dir",
"image/targa": "image/tga",
"image/x-emf": "image/emf",
"text/css": "text/code",
"text/csv": "x-office/spreadsheet",
"text/html": "text/code",
Expand All @@ -109,15 +118,7 @@ OC.MimeTypeList={
"text/x-python": "text/code",
"text/x-rst": "text",
"text/x-shellscript": "text/code",
"web": "text/code",
"application/internet-shortcut": "link",
"application/km": "mindmap",
"application/x-freemind": "mindmap",
"application/vnd.xmind.workbook": "mindmap",
"image/targa": "image/tga",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template",
"image/x-emf": "image/emf"
"web": "text/code"
},
files: [
"application",
Expand Down
9 changes: 8 additions & 1 deletion lib/private/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Resources\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Notification\IManager as INotificationManager;
Expand Down Expand Up @@ -201,7 +204,11 @@ public static function getRepairSteps(): array {
public static function getExpensiveRepairSteps() {
return [
new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager()),
new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
new RepairMimeTypes(
\OCP\Server::get(IConfig::class),
\OCP\Server::get(IAppConfig::class),
\OCP\Server::get(IDBConnection::class)
),
\OC::$server->get(ValidatePhoneNumber::class),
\OC::$server->get(DeleteSchedulingObjects::class),
];
Expand Down
102 changes: 72 additions & 30 deletions lib/private/Repair/RepairMimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OCP\DB\Exception;
use OCP\DB\IResult;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
Expand All @@ -24,6 +25,7 @@ class RepairMimeTypes implements IRepairStep {

public function __construct(
protected IConfig $config,
protected IAppConfig $appConfig,
protected IDBConnection $connection
) {
}
Expand Down Expand Up @@ -91,29 +93,7 @@ private function updateMimetypes($updatedMimetypes): IResult|int|null {

/**
* @throws Exception
*/
private function introduceExcalidrawType(): IResult|int|null {
$updatedMimetypes = [
'excalidraw' => 'application/vnd.excalidraw+json',
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* @throws Exception
*/
private function introduceAsciidocType(): IResult|int|null {
$updatedMimetypes = [
'adoc' => 'text/asciidoc',
'asciidoc' => 'text/asciidoc',
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* @throws Exception
* @since 12.0.0.14
*/
private function introduceImageTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -126,6 +106,7 @@ private function introduceImageTypes(): IResult|int|null {

/**
* @throws Exception
* @since 12.0.0.13
*/
private function introduceWindowsProgramTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -139,6 +120,7 @@ private function introduceWindowsProgramTypes(): IResult|int|null {

/**
* @throws Exception
* @since 13.0.0.0
*/
private function introduceLocationTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -153,6 +135,7 @@ private function introduceLocationTypes(): IResult|int|null {

/**
* @throws Exception
* @since 13.0.0.3
*/
private function introduceInternetShortcutTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -165,6 +148,7 @@ private function introduceInternetShortcutTypes(): IResult|int|null {

/**
* @throws Exception
* @since 13.0.0.6
*/
private function introduceStreamingTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -178,6 +162,7 @@ private function introduceStreamingTypes(): IResult|int|null {

/**
* @throws Exception
* @since 14.0.0.8
*/
private function introduceVisioTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -194,6 +179,7 @@ private function introduceVisioTypes(): IResult|int|null {

/**
* @throws Exception
* @since 14.0.0.10
*/
private function introduceComicbookTypes(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -210,6 +196,7 @@ private function introduceComicbookTypes(): IResult|int|null {

/**
* @throws Exception
* @since 20.0.0.5
*/
private function introduceOpenDocumentTemplates(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -224,6 +211,19 @@ private function introduceOpenDocumentTemplates(): IResult|int|null {

/**
* @throws Exception
* @since 21.0.0.7
*/
private function introduceOrgModeType(): IResult|int|null {
$updatedMimetypes = [
'org' => 'text/org'
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* @throws Exception
* @since 23.0.0.2
*/
private function introduceFlatOpenDocumentType(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -238,29 +238,33 @@ private function introduceFlatOpenDocumentType(): IResult|int|null {

/**
* @throws Exception
* @since 25.0.0.2
*/
private function introduceOrgModeType(): IResult|int|null {
private function introduceOnlyofficeFormType(): IResult|int|null {
$updatedMimetypes = [
'org' => 'text/org'
'oform' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform',
'docxf' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf',
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* @throws Exception
* @since 26.0.0.1
*/
private function introduceOnlyofficeFormType(): IResult|int|null {
private function introduceAsciidocType(): IResult|int|null {
$updatedMimetypes = [
'oform' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform',
'docxf' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf',
'adoc' => 'text/asciidoc',
'asciidoc' => 'text/asciidoc',
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* @throws Exception
* @since 28.0.0.5
*/
private function introduceEnhancedMetafileFormatType(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -272,6 +276,7 @@ private function introduceEnhancedMetafileFormatType(): IResult|int|null {

/**
* @throws Exception
* @since 29.0.0.2
*/
private function introduceEmlAndMsgFormatType(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -284,6 +289,7 @@ private function introduceEmlAndMsgFormatType(): IResult|int|null {

/**
* @throws Exception
* @since 29.0.0.6
*/
private function introduceAacAudioType(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -295,6 +301,7 @@ private function introduceAacAudioType(): IResult|int|null {

/**
* @throws Exception
* @since 29.0.10
*/
private function introduceReStructuredTextFormatType(): IResult|int|null {
$updatedMimetypes = [
Expand All @@ -305,6 +312,33 @@ private function introduceReStructuredTextFormatType(): IResult|int|null {
}

/**
* @throws Exception
* @since 30.0.0
*/
private function introduceExcalidrawType(): IResult|int|null {
$updatedMimetypes = [
'excalidraw' => 'application/vnd.excalidraw+json',
];

return $this->updateMimetypes($updatedMimetypes);
}


/**
* @throws Exception
* @since 31.0.0
*/
private function introduceZstType(): IResult|int|null {
$updatedMimetypes = [
'zst' => 'application/zstd',
];

return $this->updateMimetypes($updatedMimetypes);
}

/**
* Check if there are any migrations available
*
* @throws Exception
*/
public function migrationsAvailable(): bool {
Expand All @@ -314,11 +348,14 @@ public function migrationsAvailable(): bool {
return $this->changeCount > 0;
}

/**
* Get the current mimetype version
*/
private function getMimeTypeVersion(): string {
$serverVersion = $this->config->getSystemValueString('version', '0.0.0');
// 29.0.0.10 is the last version with a mimetype migration before it was moved to a separate version number
if (version_compare($serverVersion, '29.0.0.10', '>')) {
return $this->config->getAppValue('files', 'mimetype_version', '29.0.0.10');
return $this->appConfig->getValueString('files', 'mimetype_version', '29.0.0.10');
}

return $serverVersion;
Expand All @@ -335,6 +372,7 @@ public function run(IOutput $out): void {

// NOTE TO DEVELOPERS: when adding new mime types, please make sure to
// add a version comparison to avoid doing it every time
// PLEASE ALSO KEEP THE LIST SORTED BY VERSION NUMBER

if (version_compare($mimeTypeVersion, '12.0.0.14', '<') && $this->introduceImageTypes()) {
$out->info('Fixed image mime types');
Expand Down Expand Up @@ -404,8 +442,12 @@ public function run(IOutput $out): void {
$out->info('Fixed Excalidraw mime type');
}

if (version_compare($mimeTypeVersion, '31.0.0.0', '<') && $this->introduceZstType()) {
$out->info('Fixed zst mime type');
}

if (!$this->dryRun) {
$this->config->setAppValue('files', 'mimetype_version', $serverVersion);
$this->appConfig->setValueString('files', 'mimetype_version', $serverVersion);
}
}
}
Loading