feat(core): add human readable mimes

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
pull/52822/head
John Molakvoæ (skjnldsv) 2025-05-14 18:12:23 +07:00
parent 3aae7ae305
commit 24bc1d606e
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
12 changed files with 9674 additions and 11 deletions

@ -15,7 +15,7 @@ class GenerateMimetypeFileBuilder {
* @param array<string,string> $aliases
* @return string
*/
public function generateFile(array $aliases): string {
public function generateFile(array $aliases, array $names): string {
// Remove comments
$aliases = array_filter($aliases, static function ($key) {
// Single digit extensions will be treated as integers
@ -71,6 +71,15 @@ class GenerateMimetypeFileBuilder {
sort($themes[$theme]);
}
$namesOutput = '';
foreach ($names as $key => $name) {
if (str_starts_with($key, '_')) {
// Skip internal names
continue;
}
$namesOutput .= "'$key': t('core', " . json_encode($name) . "),\n";
}
//Generate the JS
return '/**
* This file is automatically generated
@ -83,7 +92,8 @@ class GenerateMimetypeFileBuilder {
OC.MimeTypeList={
aliases: ' . json_encode($aliases, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . ',
files: ' . json_encode($files, JSON_PRETTY_PRINT) . ',
themes: ' . json_encode($themes, JSON_PRETTY_PRINT) . '
themes: ' . json_encode($themes, JSON_PRETTY_PRINT) . ',
names: {' . $namesOutput . '},
};
';
}

@ -32,7 +32,8 @@ class UpdateJS extends Command {
// Output the JS
$generatedMimetypeFile = new GenerateMimetypeFileBuilder();
file_put_contents(\OC::$SERVERROOT . '/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases));
$namings = $this->mimetypeDetector->getAllNamings();
file_put_contents(\OC::$SERVERROOT . '/core/js/mimetypelist.js', $generatedMimetypeFile->generateFile($aliases, $namings));
$output->writeln('<info>mimetypelist.js is updated');
return 0;

@ -81,7 +81,6 @@ OC.MimeTypeList={
"application/x-7z-compressed": "package/x-generic",
"application/x-bzip2": "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-fictionbook+xml": "text",
@ -115,6 +114,7 @@ OC.MimeTypeList={
"text/x-h": "text/code",
"text/x-java-source": "text/code",
"text/x-ldif": "text/code",
"text/x-nfo": "text/code",
"text/x-python": "text/code",
"text/x-rst": "text",
"text/x-shellscript": "text/code",
@ -151,5 +151,110 @@ OC.MimeTypeList={
"x-office-presentation",
"x-office-spreadsheet"
],
themes: []
themes: [],
names: {'application/epub+zip': t('core', "Electronic book document"),
'application/gpx+xml': t('core', "GPX geographic data"),
'application/gzip': t('core', "Gzip archive"),
'application/illustrator': t('core', "Adobe Illustrator document"),
'application/json': t('core', "JSON document"),
'application/msword': t('core', "Word document"),
'application/octet-stream': t('core', "Unknown"),
'application/pdf': t('core', "PDF document"),
'application/postscript': t('core', "PostScript document"),
'application/rss+xml': t('core', "RSS summary"),
'application/vnd.android.package-archive': t('core', "Android package"),
'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"),
'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"),
'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"),
'application/vnd.ms-excel': t('core', "Excel spreadsheet"),
'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"),
'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"),
'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"),
'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"),
'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"),
'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"),
'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"),
'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"),
'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"),
'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"),
'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"),
'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"),
'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"),
'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"),
'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"),
'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"),
'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"),
'application/vnd.oasis.opendocument.text': t('core', "ODT document"),
'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"),
'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"),
'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"),
'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"),
'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"),
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"),
'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"),
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"),
'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"),
'application/vnd.visio': t('core', "Microsoft Visio document"),
'application/vnd.wordperfect': t('core', "WordPerfect document"),
'application/x-7z-compressed': t('core', "7-zip archive"),
'application/x-blender': t('core', "Blender scene"),
'application/x-bzip2': t('core', "Bzip2 archive"),
'application/x-fictionbook+xml': t('core', "FictionBook document"),
'application/x-krita': t('core', "Krita document"),
'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"),
'application/x-msi': t('core', "Windows Installer package"),
'application/x-perl': t('core', "Perl script"),
'application/x-php': t('core', "PHP script"),
'application/x-tar': t('core', "Tar archive"),
'application/xml': t('core', "XML document"),
'application/yaml': t('core', "YAML document"),
'application/zip': t('core', "Zip archive"),
'application/zstd': t('core', "Zstandard archive"),
'audio/aac': t('core', "AAC audio"),
'audio/flac': t('core', "FLAC audio"),
'audio/mp4': t('core', "MPEG-4 audio"),
'audio/mpeg': t('core', "MP3 audio"),
'audio/ogg': t('core', "Ogg audio"),
'audio/webm': t('core', "WebM audio"),
'audio/x-scpls': t('core', "MP3 ShoutCast playlist"),
'image/bmp': t('core', "Windows BMP image"),
'image/emf': t('core', "EMF image"),
'image/gif': t('core', "GIF image"),
'image/heif': t('core', "HEIF image"),
'image/jp2': t('core', "JPEG-2000 JP2 image"),
'image/jpeg': t('core', "JPEG image"),
'image/png': t('core', "PNG image"),
'image/svg+xml': t('core', "SVG image"),
'image/tiff': t('core', "TIFF image"),
'image/webp': t('core', "WebP image"),
'image/x-dcraw': t('core', "Digital raw image"),
'message/rfc822': t('core', "Email message"),
'text/calendar': t('core', "VCS\/ICS calendar"),
'text/css': t('core', "CSS stylesheet"),
'text/csv': t('core', "CSV document"),
'text/html': t('core', "HTML document"),
'text/markdown': t('core', "Markdown document"),
'text/org': t('core', "Org-mode file"),
'text/plain': t('core', "Plain text document"),
'text/vcard': t('core', "Electronic business card"),
'text/x-c++src': t('core', "C++ source code"),
'text/x-ldif': t('core', "LDIF address book"),
'text/x-nfo': t('core', "NFO document"),
'text/x-python': t('core', "Python script"),
'text/x-rst': t('core', "ReStructuredText document"),
'video/3gpp': t('core', "3GPP multimedia file"),
'video/dv': t('core', "DV video"),
'video/mp2t': t('core', "MPEG-2 transport stream"),
'video/mp4': t('core', "MPEG-4 video"),
'video/mpeg': t('core', "MPEG video"),
'video/ogg': t('core', "Ogg video"),
'video/quicktime': t('core', "QuickTime video"),
'video/webm': t('core', "WebM video"),
'video/x-flv': t('core', "Flash video"),
'video/x-matroska': t('core', "Matroska video"),
'video/x-ms-wmv': t('core', "Windows Media video"),
},
};

@ -23,6 +23,7 @@ use Psr\Log\LoggerInterface;
class Detection implements IMimeTypeDetector {
private const CUSTOM_MIMETYPEMAPPING = 'mimetypemapping.json';
private const CUSTOM_MIMETYPEALIASES = 'mimetypealiases.json';
private const CUSTOM_MIMETYPENAMES = 'mimetypenames.json';
/** @var array<list{string, string|null}> */
protected array $mimeTypes = [];
@ -31,6 +32,8 @@ class Detection implements IMimeTypeDetector {
protected array $mimeTypeIcons = [];
/** @var array<string,string> */
protected array $mimeTypeAlias = [];
/** @var array<string,string> */
protected array $mimeTypesNames = [];
public function __construct(
private IURLGenerator $urlGenerator,
@ -148,6 +151,25 @@ class Detection implements IMimeTypeDetector {
return $this->mimeTypes;
}
private function loadNamings(): void {
if (!empty($this->mimeTypesNames)) {
return;
}
$mimeTypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypenames.dist.json'), true);
$mimeTypeMapping = $this->loadCustomDefinitions(self::CUSTOM_MIMETYPENAMES, $mimeTypeMapping);
$this->mimeTypesNames = $mimeTypeMapping;
}
/**
* @return array<string,string>
*/
public function getAllNamings(): array {
$this->loadNamings();
return $this->mimeTypesNames;
}
/**
* detect MIME type only based on filename, content of file is not used
*

@ -148,10 +148,10 @@ class Checker {
}
if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') {
$oldMimetypeList = new GenerateMimetypeFileBuilder();
$newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases());
$newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases(), $this->mimeTypeDetector->getAllNamings());
$oldFile = $this->fileAccessHelper->file_get_contents($filename);
if ($newFile === $oldFile) {
$hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases()));
$hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases(), $this->mimeTypeDetector->getAllNamings()));
continue;
}
}

@ -87,4 +87,12 @@ interface IMimeTypeDetector {
* @since 32.0.0
*/
public function getAllMappings(): array;
/**
* Get all human readable mime names
*
* @return array<string,string>
* @since 32.0.0
*/
public function getAllNamings(): array;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,57 @@
#!/bin/bash
set -e
# Paths
MIME_JSON="mimetypemapping.dist.json"
XML_FILE="freedesktop.org.xml"
OUTPUT_JSON="mimetypenames.dist.json"
echo "1/ Extracting MIME types from $MIME_JSON"
# Extract all unique MIME types (excluding _comment keys)
MIME_TYPES=$(jq -r 'with_entries(select(.key | startswith("_") | not)) | to_entries | map(.value[]) | unique | .[]' "$MIME_JSON")
echo "Found $(echo "$MIME_TYPES" | wc -l) unique MIME types"
echo "2/ Downloading freedesktop.org XML file"
curl -sSL "https://gitlab.freedesktop.org/xdg/shared-mime-info/-/raw/03cb97596e90feda547c9b6a2addd656b14d1598/data/freedesktop.org.xml.in" > "$XML_FILE"
echo "Downloaded XML file to $XML_FILE"
echo "3/ Creating or updating MIME name mapping"
# Start from existing output if it exists, or create an empty one
if [ -f "$OUTPUT_JSON" ]; then
cp "$OUTPUT_JSON" "$OUTPUT_JSON.tmp"
else
echo "{}" > "$OUTPUT_JSON.tmp"
fi
# Track stats
MATCHED_COUNT=0
MISSING_COUNT=0
# Process each MIME type
while read -r MIME; do
echo "Processing: $MIME"
# Extract comment with XML namespace handling
COMMENT=$(xmlstarlet sel -N x="http://www.freedesktop.org/standards/shared-mime-info" \
-t -m "//x:mime-type[@type='${MIME}']" -v "x:comment" -n "$XML_FILE" | head -n 1)
if [ -n "$COMMENT" ]; then
ESCAPED_COMMENT=$(echo "$COMMENT" | sed 's/"/\\"/g')
jq --arg key "$MIME" --arg value "$ESCAPED_COMMENT" '. + {($key): $value}' "$OUTPUT_JSON.tmp" > "$OUTPUT_JSON.tmp2" && mv "$OUTPUT_JSON.tmp2" "$OUTPUT_JSON.tmp"
MATCHED_COUNT=$((MATCHED_COUNT + 1))
else
echo " > Warning: No description found for MIME type $MIME ⚠️"
MISSING_COUNT=$((MISSING_COUNT + 1))
fi
done <<< "$MIME_TYPES"
# Final formatting
jq '.' "$OUTPUT_JSON.tmp" > "$OUTPUT_JSON" && rm "$OUTPUT_JSON.tmp"
echo "✅ Done!"
echo "✔️ Descriptions found for $MATCHED_COUNT MIME types"
echo "⚠️ Descriptions missing for $MISSING_COUNT MIME types"
echo "📄 Output written to $OUTPUT_JSON"

@ -0,0 +1,114 @@
{
"_comment" : "Array of human readable mimes.",
"_comment2": "Any changes you make here will be overwritten on an update of Nextcloud.",
"_comment3": "Put any custom mappings in a new file mimetypenames.json in the config/ folder of Nextcloud",
"_comment4": "After any change to mimetypenames.json run:",
"_comment5": "./occ maintenance:mimetype:update-js",
"_comment6": "Otherwise your update won't propagate through the system.",
"application/epub+zip": "Electronic book document",
"application/gpx+xml": "GPX geographic data",
"application/gzip": "Gzip archive",
"application/illustrator": "Adobe Illustrator document",
"application/json": "JSON document",
"application/msword": "Word document",
"application/octet-stream": "Unknown",
"application/pdf": "PDF document",
"application/postscript": "PostScript document",
"application/rss+xml": "RSS summary",
"application/vnd.android.package-archive": "Android package",
"application/vnd.google-earth.kml+xml": "KML geographic data",
"application/vnd.google-earth.kmz": "KML geographic compressed data",
"application/vnd.lotus-wordpro": "Lotus Word Pro document",
"application/vnd.ms-excel": "Excel spreadsheet",
"application/vnd.ms-excel.addin.macroEnabled.12": "Excel add-in",
"application/vnd.ms-excel.sheet.binary.macroEnabled.12": "Excel 2007 binary spreadsheet",
"application/vnd.ms-excel.sheet.macroEnabled.12": "Excel spreadsheet",
"application/vnd.ms-excel.template.macroEnabled.12": "Excel spreadsheet template",
"application/vnd.ms-powerpoint": "PowerPoint presentation",
"application/vnd.ms-powerpoint.addin.macroEnabled.12": "PowerPoint add-in",
"application/vnd.ms-powerpoint.presentation.macroEnabled.12": "PowerPoint presentation",
"application/vnd.ms-powerpoint.slideshow.macroEnabled.12": "PowerPoint presentation",
"application/vnd.ms-powerpoint.template.macroEnabled.12": "PowerPoint presentation template",
"application/vnd.ms-word.document.macroEnabled.12": "Word document",
"application/vnd.oasis.opendocument.graphics": "ODG drawing",
"application/vnd.oasis.opendocument.graphics-flat-xml": "ODG drawing (Flat XML)",
"application/vnd.oasis.opendocument.graphics-template": "ODG template",
"application/vnd.oasis.opendocument.presentation": "ODP presentation",
"application/vnd.oasis.opendocument.presentation-flat-xml": "ODP presentation (Flat XML)",
"application/vnd.oasis.opendocument.presentation-template": "ODP template",
"application/vnd.oasis.opendocument.spreadsheet": "ODS spreadsheet",
"application/vnd.oasis.opendocument.spreadsheet-flat-xml": "ODS spreadsheet (Flat XML)",
"application/vnd.oasis.opendocument.spreadsheet-template": "ODS template",
"application/vnd.oasis.opendocument.text": "ODT document",
"application/vnd.oasis.opendocument.text-flat-xml": "ODT document (Flat XML)",
"application/vnd.oasis.opendocument.text-template": "ODT template",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "PowerPoint 2007 presentation",
"application/vnd.openxmlformats-officedocument.presentationml.slideshow": "PowerPoint 2007 show",
"application/vnd.openxmlformats-officedocument.presentationml.template": "PowerPoint 2007 presentation template",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "Excel 2007 spreadsheet",
"application/vnd.openxmlformats-officedocument.spreadsheetml.template": "Excel 2007 spreadsheet template",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "Word 2007 document",
"application/vnd.openxmlformats-officedocument.wordprocessingml.template": "Word 2007 document template",
"application/vnd.visio": "Microsoft Visio document",
"application/vnd.wordperfect": "WordPerfect document",
"application/x-7z-compressed": "7-zip archive",
"application/x-blender": "Blender scene",
"application/x-bzip2": "Bzip2 archive",
"application/x-fictionbook+xml": "FictionBook document",
"application/x-krita": "Krita document",
"application/x-mobipocket-ebook": "Mobipocket e-book",
"application/x-msi": "Windows Installer package",
"application/x-perl": "Perl script",
"application/x-php": "PHP script",
"application/x-tar": "Tar archive",
"application/xml": "XML document",
"application/yaml": "YAML document",
"application/zip": "Zip archive",
"application/zstd": "Zstandard archive",
"audio/aac": "AAC audio",
"audio/flac": "FLAC audio",
"audio/mp4": "MPEG-4 audio",
"audio/mpeg": "MP3 audio",
"audio/ogg": "Ogg audio",
"audio/webm": "WebM audio",
"audio/x-scpls": "MP3 ShoutCast playlist",
"image/bmp": "Windows BMP image",
"image/emf": "EMF image",
"image/gif": "GIF image",
"image/heif": "HEIF image",
"image/jp2": "JPEG-2000 JP2 image",
"image/jpeg": "JPEG image",
"image/png": "PNG image",
"image/svg+xml": "SVG image",
"image/tiff": "TIFF image",
"image/webp": "WebP image",
"image/x-dcraw": "Digital raw image",
"message/rfc822": "Email message",
"text/calendar": "VCS/ICS calendar",
"text/css": "CSS stylesheet",
"text/csv": "CSV document",
"text/html": "HTML document",
"text/markdown": "Markdown document",
"text/org": "Org-mode file",
"text/plain": "Plain text document",
"text/vcard": "Electronic business card",
"text/x-c++src": "C++ source code",
"text/x-ldif": "LDIF address book",
"text/x-nfo": "NFO document",
"text/x-python": "Python script",
"text/x-rst": "ReStructuredText document",
"video/3gpp": "3GPP multimedia file",
"video/dv": "DV video",
"video/mp2t": "MPEG-2 transport stream",
"video/mp4": "MPEG-4 video",
"video/mpeg": "MPEG video",
"video/ogg": "Ogg video",
"video/quicktime": "QuickTime video",
"video/webm": "WebM video",
"video/x-flv": "Flash video",
"video/x-matroska": "Matroska video",
"video/x-ms-wmv": "Windows Media video",
"application/vnd.oasis.opendocument.formula": "ODF formula"
}

@ -152,5 +152,111 @@ OC.MimeTypeList={
"x-office-presentation",
"x-office-spreadsheet"
],
themes: []
themes: [],
names: {'application/epub+zip': t('core', "Electronic book document"),
'application/gpx+xml': t('core', "GPX geographic data"),
'application/gzip': t('core', "Gzip archive"),
'application/illustrator': t('core', "Adobe Illustrator document"),
'application/json': t('core', "JSON document"),
'application/msword': t('core', "Word document"),
'application/octet-stream': t('core', "Unknown"),
'application/pdf': t('core', "PDF document"),
'application/postscript': t('core', "PostScript document"),
'application/rss+xml': t('core', "RSS summary"),
'application/vnd.android.package-archive': t('core', "Android package"),
'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"),
'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"),
'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"),
'application/vnd.ms-excel': t('core', "Excel spreadsheet"),
'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"),
'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"),
'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"),
'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"),
'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"),
'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"),
'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"),
'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"),
'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"),
'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"),
'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"),
'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"),
'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"),
'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"),
'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"),
'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"),
'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"),
'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"),
'application/vnd.oasis.opendocument.text': t('core', "ODT document"),
'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"),
'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"),
'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"),
'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"),
'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"),
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"),
'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"),
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"),
'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"),
'application/vnd.visio': t('core', "Microsoft Visio document"),
'application/vnd.wordperfect': t('core', "WordPerfect document"),
'application/x-7z-compressed': t('core', "7-zip archive"),
'application/x-blender': t('core', "Blender scene"),
'application/x-bzip2': t('core', "Bzip2 archive"),
'application/x-fictionbook+xml': t('core', "FictionBook document"),
'application/x-krita': t('core', "Krita document"),
'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"),
'application/x-msi': t('core', "Windows Installer package"),
'application/x-perl': t('core', "Perl script"),
'application/x-php': t('core', "PHP script"),
'application/x-tar': t('core', "Tar archive"),
'application/xml': t('core', "XML document"),
'application/yaml': t('core', "YAML document"),
'application/zip': t('core', "Zip archive"),
'application/zstd': t('core', "Zstandard archive"),
'audio/aac': t('core', "AAC audio"),
'audio/flac': t('core', "FLAC audio"),
'audio/mp4': t('core', "MPEG-4 audio"),
'audio/mpeg': t('core', "MP3 audio"),
'audio/ogg': t('core', "Ogg audio"),
'audio/webm': t('core', "WebM audio"),
'audio/x-scpls': t('core', "MP3 ShoutCast playlist"),
'image/bmp': t('core', "Windows BMP image"),
'image/emf': t('core', "EMF image"),
'image/gif': t('core', "GIF image"),
'image/heif': t('core', "HEIF image"),
'image/jp2': t('core', "JPEG-2000 JP2 image"),
'image/jpeg': t('core', "JPEG image"),
'image/png': t('core', "PNG image"),
'image/svg+xml': t('core', "SVG image"),
'image/tiff': t('core', "TIFF image"),
'image/webp': t('core', "WebP image"),
'image/x-dcraw': t('core', "Digital raw image"),
'message/rfc822': t('core', "Email message"),
'text/calendar': t('core', "VCS\/ICS calendar"),
'text/css': t('core', "CSS stylesheet"),
'text/csv': t('core', "CSV document"),
'text/html': t('core', "HTML document"),
'text/markdown': t('core', "Markdown document"),
'text/org': t('core', "Org-mode file"),
'text/plain': t('core', "Plain text document"),
'text/vcard': t('core', "Electronic business card"),
'text/x-c++src': t('core', "C++ source code"),
'text/x-ldif': t('core', "LDIF address book"),
'text/x-nfo': t('core', "NFO document"),
'text/x-python': t('core', "Python script"),
'text/x-rst': t('core', "ReStructuredText document"),
'video/3gpp': t('core', "3GPP multimedia file"),
'video/dv': t('core', "DV video"),
'video/mp2t': t('core', "MPEG-2 transport stream"),
'video/mp4': t('core', "MPEG-4 video"),
'video/mpeg': t('core', "MPEG video"),
'video/ogg': t('core', "Ogg video"),
'video/quicktime': t('core', "QuickTime video"),
'video/webm': t('core', "WebM video"),
'video/x-flv': t('core', "Flash video"),
'video/x-matroska': t('core', "Matroska video"),
'video/x-ms-wmv': t('core', "Windows Media video"),
'my-custom/mimetype': t('core', "Custom Document"),
},
};

@ -1,7 +1,7 @@
{
"hashes": {
"core\/js\/mimetypelist.js": "46f0174073339b822fc7d4a0f02bda57f211eb85b42995bd300232e77712ca05e14f6491f67c7b2da76d90b94fde8e16e01f5258a7586c2498d66247f81feaf8"
"core\/js\/mimetypelist.js": "1f672ccc11dd5f0cf8753461476b05fbf6fec018db00fc59b074947953ba99481103f84ace140255995278da7ef4e3b49d263cc29a4b29786fb19413083fe928"
},
"signature": "ZTndGos1JFlIVm38RMTuSWaD32D09kJ8yiin7zlXpF4NWJmcOca2WQQOtgnBxcawSS6Udh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dtIjQbDxqWTHh1zUSrw9wrlklCBZ\/zrM0\r\ni8nfCFwTxWRxp3H9KoECzO\/zS5R5KIS7s3\/wq\/w9T2Ie4rcecgXwDizwnn0C\/aKc\r\nbDIjujpL1s9HO05pcD\/V3wKcPZ1izymBkmMyIbL52iRVN5FTVHeZdXPpFuq+CTQJ\r\nQ238lC+A\/KOVAgMBAAEwDQYJKoZIhvcNAQEFBQADggIBAGoKTnh8RfJV4sQItVC2\r\nAvfJagkrIqZ3iiQTUBQGTKBsTnAqE1H7QgUSV9vSd+8rgvHkyZsRjmtyR1e3A6Ji\r\noNCXUbExC\/0iCPUqdHZIVb+Lc\/vWuv4ByFMybGPydgtLoEUX2ZrKFWmcgZFDUSRd\r\n9Uj26vtUhCC4bU4jgu6hIrR9IuxOBLQUxGTRZyAcXvj7obqRAEZwFAKQgFpfpqTb\r\nH+kjcbZSaAlLVSF7vBc1syyI8RGYbqpwvtREqJtl5IEIwe6huEqJ3zPnlP2th\/55\r\ncf3Fovj6JJgbb9XFxrdnsOsDOu\/tpnaRWlvv5ib4+SzG5wWFT5UUEo4Wg2STQiiX\r\nuVSRQxK1LE1yg84bs3NZk9FSQh4B8vZVuRr5FaJsZZkwlFlhRO\/\/+TJtXRbyNgsf\r\noMRZGi8DLGU2SGEAHcRH\/QZHq\/XDUWVzdxrSBYcy7GSpT7UDVzGv1rEJUrn5veP1\r\n0KmauAqtiIaYRm4f6YBsn0INcZxzIPZ0p8qFtVZBPeHhvQtvOt0iXI\/XUxEWOa2F\r\nK2EqhErgMK\/N07U1JJJay5tYZRtvkGq46oP\/5kQG8hYST0MDK6VihJoPpvCmAm4E\r\npEYKQ96x6A4EH9Y9mZlYozH\/eqmxPbTK8n89\/p7Ydun4rI+B2iiLnY8REWWy6+UQ\r\nV204fGUkJqW5CrKy3P3XvY9X\r\n-----END CERTIFICATE-----"
}

@ -713,7 +713,9 @@ class CheckerTest extends TestCase {
*/
public function testVerifyCoreSignatureWithModifiedMimetypelistSignatureData(): void {
$shippedMimetypeAliases = (array)json_decode(file_get_contents(\OC::$SERVERROOT . '/resources/config/mimetypealiases.dist.json'));
$shippedMimetypeNames = (array)json_decode(file_get_contents(\OC::$SERVERROOT . '/resources/config/mimetypenames.dist.json'));
$allAliases = array_merge($shippedMimetypeAliases, ['my-custom/mimetype' => 'custom']);
$allMimetypeNames = array_merge($shippedMimetypeNames, ['my-custom/mimetype' => 'Custom Document']);
$this->mimeTypeDetector
->method('getOnlyDefaultAliases')
@ -723,9 +725,14 @@ class CheckerTest extends TestCase {
->method('getAllAliases')
->willReturn($allAliases);
$this->mimeTypeDetector
->method('getAllNamings')
->willReturn($allMimetypeNames);
$oldMimetypeList = new GenerateMimetypeFileBuilder();
$all = $this->mimeTypeDetector->getAllAliases();
$newFile = $oldMimetypeList->generateFile($all);
$namings = $this->mimeTypeDetector->getAllNamings();
$newFile = $oldMimetypeList->generateFile($all, $namings);
// When updating the mimetype list the test assets need to be updated as well
// 1. Update core/js/mimetypelist.js with the new generated js by running the test with the next line uncommented: