Rob--W / open-in-browser

A browser extension that offers the ability to open files directly in the browser instead of downloading them.
Other
83 stars 15 forks source link

PDFJS inline display checking code doesn't seem to work #53

Closed KwanEsq closed 4 years ago

KwanEsq commented 5 years ago

So while working on #52 I've discovered that the PDFJS checking code doesn't actually seem to do anything, and just always timeouts and returns true. The first issue is a simple typo,

https://github.com/Rob--W/open-in-browser/blob/26df4dbaa2fb82a2d24ddc0d7ca30300adee2538/extension/content-handlers-firefox.js#L152-L155

using src instead of data means it doesn't try and load the file. Secondly, once that is fixed, loading the file is blocked anyway due to CSP. That can be fixed with a custom CSP in the manifest.json, like

"content_security_policy": "script-src 'self' ; object-src 'self' blob:"
Rob--W commented 5 years ago

I prefer to put the file in the repo, instead of unnecessarily relaxing the Content Security Policy.

After doing that, using .data = (or .src =? when I tested back then, the two exhibited different behaviors, if I recall correctly) should fix the detection method.

Rob--W commented 4 years ago

I've fixed the implementation. It will be added in the next release (2.11), which I haven't scheduled yet.

Rob--W commented 4 years ago

2.11 has been published.