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

PDF doesn't open in a new tab #12008

Closed
jamesray1 opened this issue Nov 17, 2017 · 8 comments
Closed

PDF doesn't open in a new tab #12008

jamesray1 opened this issue Nov 17, 2017 · 8 comments
Labels
bug duplicate Issue has already been reported plugin/pdfjs

Comments

@jamesray1
Copy link

jamesray1 commented Nov 17, 2017

Steps to Reproduce

Go to this link. The PDF doesn't load, while it does in Firefox and Chrome. Note that if you go to https://github.com/ethereum/research/blob/master/papers/CasperTFG then click on CasperTFG.pdf it will render on Github, as it does on Chrome and Firefox. If you try to open it in a new tab it doesn't load. It doesn't make a difference if all cookies are allowed, nor if Brave shields are down.

Actual result:
screenshot from 2017-11-17 14-49-11

Expected result:
screenshot from 2017-11-17 14-50-41

Reproduces how often:
100%

Brave Version

Brave: 0.19.80
rev: 7d07299
Muon: 4.5.13
libchromiumcontent: 62.0.3202.75
V8: 6.2.414.36
Node.js: 7.9.0
Update Channel: Release
OS Platform: Linux
OS Release: 4.13.0-17-generic
OS Architecture: x64

Reproducible on current live release:
Yes

@hugobuddel
Copy link
Contributor

I've had this problem as well on other sites, but not really sure what circumstances cause it.

@hugobuddel
Copy link
Contributor

The pdf does load if it is the link itself that opens the new tab (e.g. when left-clicking on a pdf-link in gmail), but not when the user opens the new tab (e.g. ctrl-clicking the pdf-link).

@hugobuddel
Copy link
Contributor

This is the same issue as #11059 ?

@luixxiul
Copy link
Contributor

CC @diracdeltas

@bsclifton bsclifton added this to the Triage Backlog milestone Nov 27, 2017
@humphd
Copy link

humphd commented Feb 16, 2018

Fixing this likely requires fixing 2 bugs. First, an HTML page is being served with a .pdf extension:

$ curl -I https://github.com/ethereum/research/blob/master/papers/CasperTFG/CasperTFG.pdf
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 16 Feb 2018 21:29:51 GMT
Content-Type: text/html; charset=utf-8

This then confuses the PDF check in js/lib/urlutil.js:

/**
   * Converts a potential PDF URL to the PDFJS URL.
   * XXX: This only looks at the URL file extension, not MIME types.
   * @param {string} url
   * @return {string}
   */
  toPDFJSLocation: function (url) {
    if (url && UrlUtil.isHttpOrHttps(url) && UrlUtil.isFileType(url, 'pdf')) {
      return UrlUtil.getPDFViewerUrl(url)
    }
    return url
  },

Once that's fixed, the next problem is that brave doesn't yet know how to serve PDFs to sub-frames on a page, see my recent comments in #12992.

This is likely a dupe of #12763.

@jamesray1
Copy link
Author

jamesray1 commented Feb 17, 2018

I can copy and paste https://ethereum.github.io/yellowpaper/paper.pdf into the URL bar and it will open the PDF in the tab. Right clicking and opening the link in a new tab also works. If I left-click the link it prompts to download it. Perhaps it also has something to do with different PDF versions, e.g. if it is PDF1.5 or later, it will be compatible with browser extensions as listed here.

@jamesray1
Copy link
Author

#12763 is a dupe of #10554.

@humphd
Copy link

humphd commented Feb 17, 2018

Looks like that link both uses .pdf and also the correct mime type:

$ curl -I https://ethereum.github.io/yellowpaper/paper.pdf
HTTP/2 200
date: Sat, 17 Feb 2018 18:19:26 GMT
server: GitHub.com
content-type: application/pdf

You're right about the left-click downloading vs. showing, which I think is due to the subFrame resource type being ignored (#12992).

I'll add my notes above to that other bug.

@bsclifton bsclifton added the duplicate Issue has already been reported label Feb 28, 2018
@bsclifton bsclifton removed this from the Triage Backlog milestone Feb 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate Issue has already been reported plugin/pdfjs
Projects
None yet
Development

No branches or pull requests

6 participants