-
Notifications
You must be signed in to change notification settings - Fork 971
pdfjs needs local file access #2714
Comments
hey @diracdeltas, I think you might already have fixed this with #6330. Thanks in advance, I'm looking at this for PR #6385 where I try to open a generated PDF in a new tab |
@willy-b it's not fixed yet sadly. pdfjs is now loaded from a remote server. it gets downloaded in ~/Library/Application Support/brave-development/Extensions/jdbefljfgobbmcidnmpjamcbhnbphjnb/ so you can test changes by editing files in there directly it's using my fork at https://github.com/diracdeltas/pdf.js (built from master using 'gulp chromium') |
sweet, thanks for the info |
I took a look at this. (Thought it'd be useful to share what I found -- if it isn't, feel free to edit or delete this post for me.) Good news: this seems to be a XHR cross-origin issue. Bad news: changing extension permissions didn't seem to fix it (for me) (see next comment). I compared Google Chrome, where PDF.js can open local PDFs, with Brave. You can run something like the following in both browsers to see difference (from debugger during page load to ensure same context for good measure):
The above works on Google Chrome (from within the PDF.js extension in process of rendering a local PDF) notes / details
|
There seem to be two general possibilities to me: (1) Differences in permissions / configuration of extension? Details below: Also set same
content_script.matches was already more permissive than chrome's: This suggests to me that it is (2). (2) differences in Muon / Chromium?
The list of approved protocols is given by
(compare latest: https://chromium.googlesource.com/chromium/src/third_party/+/master/WebKit/Source/core/loader/DocumentThreadableLoader.cpp#320) The SchemeRegistry is defined in: The But this is unchanged in Brave vs. upstream Chromium. The whole CORS check only occurs if the request is "external" or not same origin Still trying to figure this out. Just thought I'd share in case it is helpful. |
Still a problem with Brave 0.13.0. Can we set a milestone for this? |
Set to 1.1.0 for now but would move up sooner if there's a fix. |
Running Brave with (I mention this because I would have thought the latter two flags would be enough if this were related to the "Access File URLs" permission.) |
IIRC PDFJS loads each PDF via XHR, which requires the CORS header, so it makes sense that disabling web security would work around it. If you could render the contribution statement PDFs in the chrome-extension://{pdfjs_id} origin, that would probably solve the issue. |
|
is the new extension updated @bsclifton ? |
@bbondy yes, it's merged into brave/pdf.js:master but i haven't built a crx from it yet. |
I have a workaround for this but it will require an extension update. |
Needed for brave/browser-laptop#2714 Auditors: @bbondy
fix #2714 requires brave/pdf.js@6b3081e test plan: 1. git clone https://github.com/brave/pdf.js and run 'gulp chromium' 2. copy 'build/chromium' to '~/Library/Application\ Support/brave-development/Extensions/jdbefljfgobbmcidnmpjamcbhnbphjnb/1.8.251' or whatever your corrresponding userData directory is 3. start Brave with PDFJS enabled and browse to a local PDF file. it should display correctly.
nvm, i found an easier way! |
fix #2714 test plan: 1. start Brave with PDFJS enabled and browse to a local PDF file. it should display correctly. the urlbar should show the 'file:' location. 2. turn off PDFJS and go to the file. it should prompt to download.
Test plan
#8645 (comment)
the pdfjs extension doesn't have the 'Access File URLs' permission, so it can't browsr
file:///
pdfs. cc @bridiverThe text was updated successfully, but these errors were encountered: