Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed magic bytes in .xopp files #1483

Open
TheAssassin opened this issue Sep 19, 2019 · 2 comments
Open

Embed magic bytes in .xopp files #1483

TheAssassin opened this issue Sep 19, 2019 · 2 comments

Comments

@TheAssassin
Copy link
Contributor

For reasons we all know, embedding magic bytes in a file, if possible, is a good idea. It makes the recognition of file types a lot more reliable than relying on extensions only.

In #1442 (comment) I showed where such bytes could be placed, and what they could look like. I simply embedded the string xopp at a static offset so it won't interfere with the existing gzip header and also doesn't touch the compressed payload.

This is a fork of the discussion in #1442 (comment) suggested by @LittleHuba.

@lciti
Copy link
Contributor

lciti commented May 15, 2020

I like the idea of magic bytes to identify the file type but I am unsure about the suggested implementation as it does not comply with the gzip header format (RFC1952). Those bytes are supposed to contain the modification time MTIME field. While xournalpp may not use it (yet?), having a confusing date (11 Oct 2029) does not sound like a good idea to me. I suggest we use one of the other fields. I think one way to do it would be using the FNAME or FCOMMENT fields. It should be as easy as using deflateSetHeader after opening the gzip file for writing.

If using FNAME:
$ hd aaa.pdf.xopp | head -1
00000000 1f 8b 08 08 00 00 00 00 00 03 78 6f 70 70 00 cd |..........xopp..|`

If using FCOMMENT:
$ hd aaa.pdf.xopp | head -1
00000000 1f 8b 08 10 00 00 00 00 00 03 78 6f 70 70 00 cd |..........xopp..|

@LittleHuba
Copy link
Member

LittleHuba commented May 15, 2020

I'd skip this and add it to the new format. This is at most a papercut issue and there is no reason to modify the current format for this.

We should be able to add this in the made_by field of ZIP-files (right after the magic bytes of the zip file itself)

@Technius Technius modified the milestones: v1.1.0, Future major version Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants