Skip to main content
Topic: MIME types (Read 2747 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

MIME types

http://www.simplemachines.org/community/index.php?topic=545966.0

QuotePart 1 - major issue:

Apparently, as seen in Part 2 below, "mime_type" in SQL table "{db_prefix}attachments" with "varchar(20)" is to short. [...]


Part 2 - minor issue:

After upgrading from SMF 1.1.21 to SMF 2.0.11 I had to fix the mime_type entries (as old SMF 1.x.xx wasn't filling them anyway), e.g. for various "Office" document types, so that these can be autmatically opened (instead of being offered as the default application/octet-stream binary download type). So this might be included in the upgrade tool:
[a list of several UPDATEs]

I feel some of this is relevant.
Bugs creator.
Features destroyer.
Template killer.

Re: MIME types

Reply #1

Yep. Definitely a bug ... had to fix that while importing Ruth's forum. finfo_file() seems  to be the proper function.
Thorsten "TE" Eurich
------------------------

Re: MIME types

Reply #2

Looks like to be able to store anything valid would be considered valid it needs to be 255.  The spec allows 127 characters (recommends no more than 64) on each side of the /

Re: MIME types

Reply #3

I tried a search and found these:
https://www.sitepoint.com/web-foundations/mime-types-complete-list/
http://www.freeformatter.com/mime-types-list.html#mime-types-list
https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
https://www.iana.org/assignments/media-types/media-types.xhtml

In particular, that last one has a nice downloadable csv from which it's easy to get the length of each official MIME up to a couple of days ago. And it looks like the longest (both sides of the / combined) is 84 characters. The longest are the MS OpenXML documents with 70+ chars.

So, if we want to stay conservative, 100 would be more than enough, otherwise we can use the 255.
Bugs creator.
Features destroyer.
Template killer.

Re: MIME types

Reply #4

Thats fine as well ... better than what we have.

I was going by https://tools.ietf.org/html/rfc6838 section 4.2 of the  Media Type Specifications which allows 127 + '/' + 127 = 256 but recommends as practical 64 + '/' + 64 = 129  .... either way the storage delta is pretty much moot given its a varchar and lenght() should simply imply whats reasonably expected ... I have no idea what reasonable is for this, but its not 20

Re: MIME types

Reply #5

Let's call 130 a deal? :P
Bugs creator.
Features destroyer.
Template killer.

Re: MIME types

Reply #6

Just go with 255. There is no reason not to. The size of the column doesn't change.

Re: MIME types

Reply #7

I think getting all of the IANA Media Types is something a mod might be better suited for. I'd say it should recognize all of the major: image types (png, bmp, jpg, gif), video types (mov, mp4, etc.), text types (txt, html, csv), MS Office document types (not the templates), and archive (zip, tar, gz, etc.) types by default.

Re: MIME types

Reply #8

Quote from: Joshua Dickerson – Just go with 255. There is no reason not to. The size of the column doesn't change.
Ohh... right, varchar takes only the space needed, I confused it with char I guess... or maybe something else entirely different. xD

Quote from: Joshua Dickerson – I think getting all of the IANA Media Types is something a mod might be better suited for.
The mime is recognized by php through finfo_open, the IANA db was just to have an idea of what are the existing mime to base the size of the field on a real-world example. ;)
Bugs creator.
Features destroyer.
Template killer.