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

Local file is downloaded by Chrome instead of being displayed #391

Open
IgorTimofeyev opened this issue Jun 19, 2020 · 3 comments
Open

Local file is downloaded by Chrome instead of being displayed #391

IgorTimofeyev opened this issue Jun 19, 2020 · 3 comments

Comments

@IgorTimofeyev
Copy link

Local file is downloaded by Chrome instead of being displayed when file contains "NULL" character, i.e. a character which HEX-code is 00

The description looks like #323 , but looking throw it I'd suppose that this is another case.

The system is Windows 10, browser - Chrome 83.0.4103.106 64bit, Asciidoctor extension - 2.6.1

@IgorTimofeyev
Copy link
Author

File (extension was changed from "adoc" to "txt" for attaching) containing NULL-character:

NULL_character_example.txt

@ggrossetie
Copy link
Member

ggrossetie commented Jun 19, 2020

Hello @IgorTimofeyev

Thanks for the detailed issue with a reproduction case 👍

I think that the file type cannot be resolved by the browser as soon as the file contains a NULL character.
In this case, the MIME type ends up being application/octet-stream and the browser decides to download it before the extension is even executed.

Resource interpreted as Document but transferred with MIME type application/octet-stream: "file:///C:/path/to/NULL_character_example.adoc".

As a workaround, you can check the "Preview files with txt extension" in the options:

preview-txt

With this setting, the browser resolves the MIME type to text/plain (because txt is a well-known extension) and decides to open it (not download it).

ok-txt

As far as I know there's nothing we can do in the extension to change this behavior.

Having said that, the AsciiDoc working group plans to register adoc as an official file extension (with text/asciidoc as a MIME-type). See: asciidoctor/asciidoctor#2502

If we do that then browsers will eventually recognize the .adoc file extension and open the content (even if it contains a NULL-character) because this file extension is associated to a textual format (just like .txt).
But it won't happen overnight so you should consider the workaround described above 😉

For reference, I can also reproduce this behavior in Firefox and Edge (Chromium).

I've added the label "upstream" since I do think that the only way to fix this issue is to register adoc as an official file extension.

@IgorTimofeyev
Copy link
Author

@Mogztter ,

Thank you for paying your attantion to the issue!

Ok, will hope and wait for regestering extension, that's ok.

Regards,
Igor

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

2 participants