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

Some context-specific sniffing algorithms don't check if supplied MIME type is undefined #181

Open
kemzeb opened this issue Nov 6, 2023 · 2 comments

Comments

@kemzeb
Copy link

kemzeb commented Nov 6, 2023

What is the issue with the MIME Sniffing Standard?

Not sure if I overlooked something, but it appears that the sniffing in an image context, audio or video context, and font context algorithms don't handle the case where the supplied MIME type may be undefined due to the fact that the supplied MIME type detection algorithm can either return a MIME type or an undefined value.

The other context-specific sniffing algorithms that would set the computed MIME type to be the supplied MIME type do have a check for this unlike the ones mentioned above.

@GPHemsley
Copy link
Member

This is indeed an underspecified area. If the algorithm can't identify the type of image/audio/video/font, what would you expect to happen? If it returned "application/octet-stream", would that be better than returning undefined? What do the browsers do in these scenarios?

@kemzeb
Copy link
Author

kemzeb commented Dec 31, 2023

I personally went with returning application/octet-stream in my implementation, and it seems the servo browser engine does the same. I haven't been able to find anything for Chrome, but this line in Firefox seems to suggest an undefined is returned if the algorithm fails to match an image signature they support.

I'm not sure if there is a benefit with choosing to return undefined over application/octet-stream. I chose the latter for my implementation of these algorithms because the rules for identifying an unknown MIME type also returns this if all else fails.

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

No branches or pull requests

2 participants