Discussions » Creation Requests

request firefox download filename bug fix

§
Posted: 2017-02-20

request firefox download filename bug fix

some site download filename is broken.

maybe filename include space

ex) test sample.rar

firefox only get 'test' filename.

https://www.codeproject.com/Tips/745949/Download-File-Firefox-Issue

how to fix?

woxxomMod
§
Posted: 2017-02-20
§
Posted: 2017-02-21
Edited: 2017-02-21

If the filename is passed from the server in the manner described on the CodeProject article, I don't think there is a way to recover the missing part of the file name.

In theory, an XMLHttpRequest HEAD request could provide access to the response headers, and that might allow reconstructing the file name. (I didn't try it.)

And then with that information you could set the download attribute on the link to supply the desired file name.

Unfortunately, Firefox gives the filename from the HTTP header precedence over the download attribute, so this method most likely would not work.

* http://dev.jeffersonscher.com/space/
* https://developer.mozilla.org/docs/Web/HTML/Element/a#Attributes

Instead of modifying the download link, using the method of downloading the file as a blob of binary data -- mentioned on StackOverflow -- might work, but I didn't look into it.

§
Posted: 2017-02-21
Edited: 2017-02-21

http://www.polarcloud.com/truncfix

truncfix is space filename fix add-on

but truncfix apply all site..

i want to white site only work..

userscript is impossable?

§
Posted: 2017-02-21
truncfix is space filename fix add-on

I don't think the method used by that extension can work in a userscript -- it modifies the HTTP header by adding the missing quotation marks:

hc.setResponseHeader("content-disposition", hc.getResponseHeader("content-disposition").replace(/(;\s*filename\s*=\s*)([^\";]+)/, "$1\"$2\"")

That requires an early intervention, before the page starts loading, so I suspect by the time Greasemonkey runs, it's too late. Not to mention that it uses privileged methods that scripts do not have access to...

So some other approach would be needed.

woxxomMod
§
Posted: 2017-02-21

Someone familiar with Firefox addon development can modify it to run only on the required site.

§
Posted: 2017-02-22

thanks! everybody

i understand

Post reply

Sign in to post a reply.