Skip to content

Commit c0e82db

Browse files
Merge pull request mozilla#7642 from Rob--W/crx-type-from-content-disposition-header
Deduct file type from content-disposition if needed
2 parents ab1b4ce + ae74e1b commit c0e82db

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

extensions/chromium/pdfHandler.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,19 @@ function isPdfFile(details) {
7373
var header = getHeaderFromHeaders(details.responseHeaders, 'content-type');
7474
if (header) {
7575
var headerValue = header.value.toLowerCase().split(';',1)[0].trim();
76-
return (headerValue === 'application/pdf' ||
77-
headerValue === 'application/octet-stream' &&
78-
details.url.toLowerCase().indexOf('.pdf') > 0);
76+
if (headerValue === 'application/pdf') {
77+
return true;
78+
}
79+
if (headerValue === 'application/octet-stream') {
80+
if (details.url.toLowerCase().indexOf('.pdf') > 0) {
81+
return true;
82+
}
83+
var cdHeader =
84+
getHeaderFromHeaders(details.responseHeaders, 'content-disposition');
85+
if (cdHeader && /\.pdf(["']|$)/i.test(cdHeader.value)) {
86+
return true;
87+
}
88+
}
7989
}
8090
}
8191

0 commit comments

Comments
 (0)