Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Allow 3p cookies in PDFJS viewer
Browse files Browse the repository at this point in the history
Otherwise some sites like Dropbox return 403 when trying to fetch
the PDF. Fix #3056.

Auditors: @bbondy
  • Loading branch information
diracdeltas committed Aug 9, 2016
1 parent 1307a9a commit 1e1e185
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const headersReceivedFilteringFns = []
let initializedPartitions = {}

const transparent1pxGif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
const pdfjsOrigin = `chrome-extension://${config.PDFJSExtensionId}`

// Third party domains that require a valid referer to work
const refererExceptions = ['use.typekit.net', 'cloud.typography.com']
Expand Down Expand Up @@ -193,7 +194,8 @@ function registerForBeforeSendHeaders (session) {
if (module.exports.isThirdPartyHost(urlParse(details.firstPartyUrl || '').hostname,
parsedUrl.hostname)) {
// Clear cookie and referer on third-party requests
if (requestHeaders['Cookie']) {
if (requestHeaders['Cookie'] &&
getOrigin(details.firstPartyUrl) !== pdfjsOrigin) {
requestHeaders['Cookie'] = undefined
}
if (requestHeaders['Referer'] &&
Expand Down

1 comment on commit 1e1e185

@bbondy
Copy link
Member

@bbondy bbondy commented on 1e1e185 Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Please sign in to comment.