keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
391 stars 108 forks source link

chore(common): register .kmx / .kmp with MIME and with magic #10967

Open srl295 opened 6 months ago

srl295 commented 6 months ago

.kmp will be challenging because the zip metadata is at the end

srl295 commented 4 months ago

The form is here https://www.iana.org/assignments/media-types/media-types.xhtml#image

@mcdurdin some questions:

extension mime Spec Link
.kmx application/vnd.keyman.kmx here
.kmp application/vnd.keyman.kmp+zip here
mcdurdin commented 4 months ago

vnd.keyman is appropriate. We have the keyman.com domain. We don't tend to use the name SIL in any internal names for Keyman, only in branding.

Happy to have my email on the form (perhaps my @keyman.com address).

srl295 commented 4 months ago
srl295 commented 4 months ago

@mcdurdin suggested MIME template

KMX

Your Full Name: ≈

Your Email: ≈

Type Name: application

Subtype Name: 
 - Vendor Tree (vnd. prefix)
 - keyman.kmx

Required Parameters: N/A

Optional Parameters: N/A

Encoding Considerations: binary

Security Considerations:  Does not contain executable content. Application must validate that all data fields are within specification and reject invalid content. 
 ** Or just “the security issues associated with this type have not been assessed” ?

Interoperability Condsiderations: N/A

Published Specification: https://help.keyman.com/developer/current-version/reference/file-types/kmx

Application Usage: This format is produced by Keyman keyboard build tools, and consumed by Keyman keyboard software.

Fragment Identifier: N/A

Restrictions on usage: N/a

Provisional: No

Magic number:  At byte offset zero, “KXTS”

File Extension:  .kmx

Intended Usage: COMMON
srl295 commented 4 months ago

and KMP

KMP

Your Full Name: ≈

Your Email: ≈

Type Name: application

Subtype Name: 
 - Vendor Tree (vnd. prefix)
 - keyman.kmp+zip

Required Parameters: N/A

Optional Parameters: N/A

Encoding Considerations: binary

Security Considerations:  As produced by Keyman tools, does not contain executable content. Application must validate that all data fields are within specification and reject invalid content.  As a zipfile, security considerations should be considered as described in https://www.iana.org/assignments/media-types/application/zip

Interoperability Condsiderations: N/A

Published Specification: https://help.keyman.com/developer/current-version/reference/file-types/kmp

Application Usage: This format is produced by Keyman keyboard build tools, and consumed by Keyman keyboard software.

Fragment Identifier: N/A

Restrictions on usage: N/a

Provisional: No

Magic Number: For zipfile: PK\003\004

File Extension:  .kmp

Intended Usage: COMMON
mcdurdin commented 4 months ago
  • .kmp is going to be hard to detect. There's no predictable order of the files. I don't see a lot of prior art for such zipfiles.

It looks like it is possible to scan from the end of the file with a negative offset. In which case, we read the EOCD record (we can assume the zip has no file comment), so the record will be 22 bytes long. Something like this seems to work (with a few safety checks along the way):

# Keyman Compiled Package File

# A zip file that contains a file named kmp.json
0   string  PK\003\004
# Check End of central directory record magic
>-22 string  PK\005\006
# Find start of central directory
>>(-6.l)   string   PK\001\002
# Scan central directory for string 'kmp.json', will suffice for a 
# package containing about 150 files
>>>(-6.l)   search/9000   kmp.json   Keyman Compiled Package File
!:ext kmp

I don't think we need to worry about kmp.inf, because that's an obsolete file format, and there will be very few .kmp files that don't have kmp.json.

Prior art on ZIP file content checks: https://github.com/file/file/blob/master/magic/Magdir/msooxml

mcdurdin commented 4 months ago

I think we should hold off on registering MIME types until we have a published spec for .kmx.

mcdurdin commented 1 month ago

I think we are unblocked now, what do we need to do to move this forward?

mcdurdin commented 2 weeks ago

MIME type applications submitted.

mcdurdin commented 2 weeks ago

Keyman mime types: https://github.com/file/file/commit/04edb32ba99ff23ff3969ee606f08dface4e1ff7

mcdurdin commented 2 days ago

We should add this information to documentation.