diff options
author | Alex Henrie <alexhenrie24@gmail.com> | 2023-11-08 07:40:42 -0700 |
---|---|---|
committer | David Faure <faure@kde.org> | 2023-11-08 15:16:08 +0000 |
commit | d4c2ed1b62b51fed1f9fa003de6cfdc6a82df729 (patch) | |
tree | cf1e954a9ba64d815bd1742b4ca3b7f1d8bdd083 | |
parent | 0628b0413a459897d032b6fd391ea5b1e5f3f421 (diff) |
Add application/x-msdownload and subtypes
application/x-msdownload is what Microsoft Windows uses for EXE and DLL
files, so that type is commonly found on the WWW and in other contexts.
It is an umbrella type for anything with a .exe or .dll file extension,
among others.
application/x-dosexec is what the `file` utility uses for DOS
executables specifically. According to the File Format Problem wiki:
"It's not clear if there is any completely reliable way to identify a
file as strictly DOS EXE, except in the negative (i.e., it looks like
EXE, and is not a valid NE, PE, etc., file)...If the relocation table
offset is from 28 to 63...it is pretty certainly DOS EXE."
application/x-ms-ne-executable is what the `file` utility uses for
16-bit Windows libraries and executables.
application/vnd.microsoft.portable-executable is the IANA standard type
for 32-bit and 64-bit Windows libraries and executables, as well as EFI
executables.
With these changes, application/x-ms-dos-executable is considered
deprecated. For now it is an alias of application/x-msdownload, but in
the future it may change to be an alias of application/x-dosexec.
helloworld-*.exe was compiled with Open Watcom from the following C
source code:
#include <stdio.h>
int main(void)
{
puts("Hello World!");
return 0;
}
https://github.com/file/file/blob/171c73b67ca692550882e0b8ab3c2a1f16ab1e00/magic/Magdir/msdos
https://www.iana.org/assignments/media-types/application/vnd.microsoft.portable-executable
http://fileformats.archiveteam.org/wiki/MS-DOS_EXE
http://fileformats.archiveteam.org/wiki/New_Executable
http://fileformats.archiveteam.org/wiki/Portable_Executable
-rw-r--r-- | data/freedesktop.org.xml.in | 61 | ||||
-rwxr-xr-x | tests/mime-detection/helloworld-dos.exe | bin | 0 -> 4790 bytes | |||
-rwxr-xr-x | tests/mime-detection/helloworld-win16.exe | bin | 0 -> 32394 bytes | |||
-rwxr-xr-x | tests/mime-detection/helloworld-win32.exe | bin | 0 -> 23552 bytes | |||
-rw-r--r-- | tests/mime-detection/list | 6 |
5 files changed, 65 insertions, 2 deletions
diff --git a/data/freedesktop.org.xml.in b/data/freedesktop.org.xml.in index cc2b929..a8eb745 100644 --- a/data/freedesktop.org.xml.in +++ b/data/freedesktop.org.xml.in @@ -3278,13 +3278,70 @@ command to generate the output files. </magic> <alias type="application/x-netscape-bookmarks"/> </mime-type> - <mime-type type="application/x-ms-dos-executable"> - <comment>DOS/Windows executable</comment> + <mime-type type="application/x-msdownload"> + <comment>Windows or DOS program</comment> + <acronym>DOS</acronym> + <expanded-acronym>Disk Operating System</expanded-acronym> + <sub-class-of type="application/x-executable"/> <generic-icon name="application-x-executable"/> <magic> <match type="string" value="MZ" offset="0"/> </magic> <glob pattern="*.exe"/> + <glob pattern="*.dll"/> + <glob pattern="*.cpl"/> + <glob pattern="*.drv"/> + <glob pattern="*.scr"/> + <alias type="application/x-ms-dos-executable"/> + </mime-type> + <mime-type type="application/x-dosexec"> + <comment>DOS executable</comment> + <acronym>DOS</acronym> + <expanded-acronym>Disk Operating System</expanded-acronym> + <sub-class-of type="application/x-msdownload"/> + <generic-icon name="application-x-executable"/> + <magic priority="60"> + <match type="string" value="MZ" offset="0"> + <match type="little16" mask="0xffc0" value="0" offset="24"/> + </match> + </magic> + <glob pattern="*.exe" weight="30"/> + </mime-type> + <mime-type type="application/x-ms-ne-executable"> + <comment>16-bit Windows program</comment> + <sub-class-of type="application/x-msdownload"/> + <generic-icon name="application-x-executable"/> + <magic priority="70"> + <match type="string" value="MZ" offset="0"> + <match type="string" value="NE" offset="64:256"/> + </match> + </magic> + <glob pattern="*.exe" weight="20"/> + <glob pattern="*.dll" weight="20"/> + <glob pattern="*.cpl" weight="20"/> + <glob pattern="*.drv" weight="20"/> + <glob pattern="*.scr" weight="20"/> + </mime-type> + <mime-type type="application/vnd.microsoft.portable-executable"> + <comment>Windows or EFI program</comment> + <acronym>EFI</acronym> + <expanded-acronym>Extensible Firmware Interface</expanded-acronym> + <sub-class-of type="application/x-msdownload"/> + <generic-icon name="application-x-executable"/> + <magic priority="80"> + <match type="string" value="MZ" offset="0"> + <match type="string" value="PE\0\0" offset="64:256"/> + </match> + </magic> + <glob pattern="*.exe" weight="40"/> + <glob pattern="*.dll" weight="40"/> + <glob pattern="*.cpl" weight="40"/> + <glob pattern="*.drv" weight="40"/> + <glob pattern="*.scr" weight="40"/> + <glob pattern="*.efi"/> + <glob pattern="*.ocx"/> + <glob pattern="*.sys"/> + <glob pattern="*.lib"/> </mime-type> <mime-type type="application/x-ms-pdb"> <comment>Windows program database</comment> diff --git a/tests/mime-detection/helloworld-dos.exe b/tests/mime-detection/helloworld-dos.exe Binary files differnew file mode 100755 index 0000000..060f7b7 --- /dev/null +++ b/tests/mime-detection/helloworld-dos.exe diff --git a/tests/mime-detection/helloworld-win16.exe b/tests/mime-detection/helloworld-win16.exe Binary files differnew file mode 100755 index 0000000..13b1648 --- /dev/null +++ b/tests/mime-detection/helloworld-win16.exe diff --git a/tests/mime-detection/helloworld-win32.exe b/tests/mime-detection/helloworld-win32.exe Binary files differnew file mode 100755 index 0000000..8870c83 --- /dev/null +++ b/tests/mime-detection/helloworld-win32.exe diff --git a/tests/mime-detection/list b/tests/mime-detection/list index ed8df78..8423f2f 100644 --- a/tests/mime-detection/list +++ b/tests/mime-detection/list @@ -838,6 +838,12 @@ ls application/x-executable x # ELF shared library libldap-2.4.so.2 application/x-sharedlib oxo boardingpass.pkpass application/vnd.apple.pkpass +# DOS executable +helloworld-dos.exe application/x-dosexec x +# 16-bit Windows executable +helloworld-win16.exe application/x-ms-ne-executable x +# 32-bit Windows executable +helloworld-win32.exe application/vnd.microsoft.portable-executable x # Generated with `cd /tmp && x86_64-w64-mingw32-clang -shared -fuse-ld=lld -Wl,--pdb=empty.pdb -x c /dev/null` empty.pdb application/x-ms-pdb x C.lnk application/x-ms-shortcut |