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

Download button ignores Content-Disposition/filename header #2407

Closed
fwenzel opened this issue Nov 25, 2012 · 14 comments · Fixed by #2635
Closed

Download button ignores Content-Disposition/filename header #2407

fwenzel opened this issue Nov 25, 2012 · 14 comments · Fixed by #2635

Comments

@fwenzel
Copy link
Member

fwenzel commented Nov 25, 2012

Look at a PDF file served at the URL "view.aspx" with the following response header:

Content-Disposition:filename=myfile.pdf

Now compare:

  • CMD/Ctrl+S -- it will open a file download dialog stating "myfile.pdf" as the target filename.
  • clicking the "download" button in pdf.js -- it will open a download dialog stating "view.aspx" as the filename.

Evidently, the download button ignores the content-disposition header, while Firefox's "download page" functionality does not.

(sorry I would give you a live example but this is a utility bill behind login)

@erikw
Copy link

erikw commented Dec 13, 2012

Yes this is a major problem, all my downloaded PDF files have the wrong name now! This should be fixed sooner than later.

@waddlesplash
Copy link
Contributor

I'm looking into it.

@yurydelendik
Copy link
Contributor

@yurydelendik
Copy link
Contributor

there is also contentDispositionFilename (http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIChannel.idl#294)

@waddlesplash
Copy link
Contributor

I'm having trouble using the following code:

const Cu = Components.utils;
Cu.import('resource://gre/modules/Services.jsm');

In the web console:

The Components object is deprecated. It will soon be removed.
TypeError: Cu is undefined

@waddlesplash
Copy link
Contributor

(from viewer.js)

@brendandahl
Copy link
Contributor

viewer.js runs with content permissions. You need to be in chrome code to use Cu. The chrome privileged code lives in https://github.com/mozilla/pdf.js/blob/master/extensions/firefox/components/PdfStreamConverter.js

@waddlesplash
Copy link
Contributor

So where should I put the code that retrieves the header and how should viewer.js access it?

@yurydelendik
Copy link
Contributor

@yurydelendik
Copy link
Contributor

Since it's mostly for the extension, if possible, place all code into PdfStreamConverter.js

@waddlesplash
Copy link
Contributor

Since it's mostly for the extension, if possible, place all code into PdfStreamConverter.js

But some code has to go into viewer.js for the download button, right?

@yurydelendik
Copy link
Contributor

But some code has to go into viewer.js for the download button, right?

I don't see why, the code in the viewer.js just executes https://github.com/mozilla/pdf.js/blob/master/extensions/firefox/components/PdfStreamConverter.js#L235

@yurydelendik
Copy link
Contributor

Fixed by #2635

@yurydelendik
Copy link
Contributor

Ctrl+S part is dup of #943

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

Successfully merging a pull request may close this issue.

5 participants