Skip to content

Commit

Permalink
Minimize changes to Content-Disposition response header
Browse files Browse the repository at this point in the history
The current Content-Disposition parser is very poor (see e.g. #26).
Let the browser determine the file name since they are probably better
at it.
  • Loading branch information
Rob--W committed Nov 25, 2017
1 parent 24e727f commit 2cc8b9c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ chrome.webRequest.onHeadersReceived.addListener(async function(details) {
// Relevant code: https://searchfox.org/mozilla-central/rev/a5d613086ab4d0578510aabe8653e58dc8d7e3e2/uriloader/exthandler/nsExternalHelperAppService.cpp#1685-1704
setHeader(details.responseHeaders, 'Content-Type', 'application/prs.oib-ask-once');
}
setHeader(details.responseHeaders, 'Content-Disposition',
'attachment; filename*=UTF-8\'\'' + encodeURIComponent(filename));
if (contentDisposition) {
setHeader(details.responseHeaders, 'Content-Disposition',
contentDisposition.replace(/^[^;]*(;?)/, 'attachment$1'));
} else {
setHeader(details.responseHeaders, 'Content-Disposition', 'attachment');
}
}
if (desiredAction.rememberChoice) {
Prefs.setMimeAction(guessedMimeType, isSniffingMimeType, desiredAction);
Expand Down

0 comments on commit 2cc8b9c

Please sign in to comment.