Do content-sniffing for HTML #566

Closed
The-Compiler opened this Issue Mar 18, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@The-Compiler
Collaborator

The-Compiler commented Mar 18, 2015

When opening a local HTML file without .html extension, qutebrowser downloads the file instead of opening it.

Instead we should detect it's HTML and open it accordingly.

Ressources:

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Aug 24, 2015

Collaborator

Fixing this would mean changing qutebrowser.browser.webpage.on_unsupported_content to sniff the reply in the else branch, and then use self.display_content accordingly.

Collaborator

The-Compiler commented Aug 24, 2015

Fixing this would mean changing qutebrowser.browser.webpage.on_unsupported_content to sniff the reply in the else branch, and then use self.display_content accordingly.

@l29ah

This comment has been minimized.

Show comment
Hide comment
@l29ah

l29ah Oct 22, 2015

I'd argue that it would make sense to view every file specified on the command line, as it should be much easier to implement and user must be knowing what is he doing when he does this. In fact, he won't ever want to "download" a local file.

l29ah commented Oct 22, 2015

I'd argue that it would make sense to view every file specified on the command line, as it should be much easier to implement and user must be knowing what is he doing when he does this. In fact, he won't ever want to "download" a local file.

@l29ah

This comment has been minimized.

Show comment
Hide comment
@l29ah

l29ah Oct 22, 2015

// in fact i'm upset that mutt can't view html in qutebrowser because it doesn't append ".html" to the temporary file's name

l29ah commented Oct 22, 2015

// in fact i'm upset that mutt can't view html in qutebrowser because it doesn't append ".html" to the temporary file's name

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Oct 22, 2015

Collaborator

Fair enough - though it still would need to set some kind of mimetype for them, and I'm not sure if it's a good idea to set text/html for everything local even if it's something completely different.

As a workaround, I think you can write a wrapper script which renames the file and launches qutebrowser on it, and then launch that from mutt.

Collaborator

The-Compiler commented Oct 22, 2015

Fair enough - though it still would need to set some kind of mimetype for them, and I'm not sure if it's a good idea to set text/html for everything local even if it's something completely different.

As a workaround, I think you can write a wrapper script which renames the file and launches qutebrowser on it, and then launch that from mutt.

@spaceone

This comment has been minimized.

Show comment
Hide comment
@spaceone

spaceone Dec 12, 2015

I wouldn't do this. I would always look at the Content-Type response header because this is the correct way to do things.
There is also a unofficial HTTP header X-Content-Type-Options which might have the value nosniff to prevent browsers (IE / Chrome) for doing such thing. Plus the Content-Disposition header should be evaluated.

I wouldn't do this. I would always look at the Content-Type response header because this is the correct way to do things.
There is also a unofficial HTTP header X-Content-Type-Options which might have the value nosniff to prevent browsers (IE / Chrome) for doing such thing. Plus the Content-Disposition header should be evaluated.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Dec 12, 2015

Collaborator

I don't think local files have HTTP headers 😉

Collaborator

The-Compiler commented Dec 12, 2015

I don't think local files have HTTP headers 😉

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Jan 24, 2017

Collaborator

Looks like qutebrowser does the right thing with QtWebEngine here, and I don't want to implement that for QtWebKit only.

Collaborator

The-Compiler commented Jan 24, 2017

Looks like qutebrowser does the right thing with QtWebEngine here, and I don't want to implement that for QtWebKit only.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Jun 7, 2018

Collaborator

Another reason to not do this: Chromium disabled mime sniffing for local files (without .html extension) for security reasons: https://bugs.chromium.org/p/chromium/issues/detail?id=777737

Collaborator

The-Compiler commented Jun 7, 2018

Another reason to not do this: Chromium disabled mime sniffing for local files (without .html extension) for security reasons: https://bugs.chromium.org/p/chromium/issues/detail?id=777737

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