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

Validity of data #6

Closed
ioquatix opened this issue Oct 9, 2016 · 6 comments
Closed

Validity of data #6

ioquatix opened this issue Oct 9, 2016 · 6 comments

Comments

@ioquatix
Copy link

ioquatix commented Oct 9, 2016

I'm looking at the text mime types.

I see text/plain includes markdown and md as extensions, but I also see text/markdown but without any extensions listed.

http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown

Is this a bug?

@ioquatix
Copy link
Author

ioquatix commented Oct 9, 2016

Another thing that strikes me as odd, is the listing of c source code under text/plain. Does that really make sense?

@halostatue
Copy link
Member

text/markdown should probably include md, mkd, and markdown as extensions, and a pull-request would be accepted.

There’s a lot of historical data in this database, and .c as text/plain is not incorrect because it is just a text file as far as most systems are concerned. Even file foo.c can’t tell you more than it being an ASCII-encoded or UTF-8 encoded text file, and that uses “magic bytes” for detection.

@ioquatix
Copy link
Author

ioquatix commented Oct 9, 2016

There are tons of files that could be considered text/plain.

cc c h hpp cpp c++ and about a billion others. But, if you only enumerate SOME of them in text/plain, is that sort of worse than only enumerating the main ones (e.g. perhaps only txt)

@halostatue
Copy link
Member

Mmm. You’re right that there are an infinite number of text/plain extensions, but these have been in the registry since very early (lib/mime/types.rb:805) and in the Perl library I ported before that. I’m sure I could find which data source I used that included that as a text extension at the time, but I didn’t arbitrarily make the decision myself.

I’m not sure it’s wrong (nor sure that it’s right), but agree that it feels weird, except when you remember that we’re talking about data that originally came from Apache httpd which used extensions to determine the way that files would be sent across the wire to the browser, and the browser which would decide to download or display the data received. At some point, someone decided that c absolutely should be displayed in-line as text if linked to and not downloaded. (This is one of the reasons why I don’t want to make the registry immutable in the Ruby implementation, so that application developers have an opportunity to modify the types that matter to their application. This is something that probably needs to be documented better.)

@ioquatix
Copy link
Author

Just so we are on the same page. I'm only arguing against immutability in the global context. For example right now, if I want to add a mime type to mail but not rack-static (as an imaginary example), it's not possible, if they both use the same global registry. To me, this is a poor design.

@halostatue
Copy link
Member

To be clear: there’s nothing about the registries (for Ruby) that require that they be global. In fact, the global registry itself is implemented as an instance of MIME::Types itself. There are memory costs involved with maintaining multiple registries, but the design permits the use of multiple registries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants