New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relative links to not work for local files (opened using 'file://' scheme) #12415
Comments
For (obvious) security reasons, browsers themselves will generally disable linking to Given that this is a security feature of browsers, there's unfortunately nothing that can be done here and the issue is thus invalid. |
The same can also be observed for relative links like That being sad the issue also occurs with relative links like I said above which - even if you would decide to not support And the corresponding code: \documentclass{article}
\usepackage{hyperref}
\begin{document}
Also see \url{www.example.com} or \url{../Downloads/link.pdf}.
\end{document} |
Please note that that kind of embedding is not something that the PDF.js library supports (or intends to support) out-of-the-box. Please also see http://mozilla.github.io/pdf.js/getting_started/#introduction (emphasis mine):
Note that relative links, using protocols such as e.g. HTML, already works in e.g. the built-in Firefox PDF viewer. This is achieved by providing the Lines 136 to 138 in 120c5c2
|
Yes but this only works when opening pdf from a URL and not for local pdf. As I and probably also many other use Firefox as their primary pdf viewer this is limiting. When starting a local file server I can open the pdf without problems and the link is visible - when opening the same file from the file explorer (e.g. the |
I do not see a reason to not include Lines 368 to 382 in 120c5c2
The only attack surface I could think of is embedded javascript inside a local pdf file which - upon opening - sends some local resources to a remote address. However I do not know whether that is possible at all given that all resources are embedded in the pdf itself. As far as I can see the above function is only used for links and as such I do not see a surface for a XSS attack. If I missed something please tell me - though most other pdf viewers I know allow such links and therefore mitigating such an attack should be possible if it exists... |
May I ask why relative links are resolved to an absolute path at all? It seems easier to just leave them as a relative link which would also fix this problem. |
I would also like to point out that firefox and chrome both support |
@Snuffleupagus would you be open for the above solution? |
No, since what you suggest is too simplistic and it would not actually work in the Firefox PDF Viewer anyway. The technical reason for this, is that the Firefox PDF Viewer actually runs with a |
Okay I see. But why is cross-origin navigation prohibited? The sole act of linking should not open an attack surface or what am I missing? |
Because otherwise e.g. a web-server (running at |
So the browser does not differentiate between a link and a resource as a link is also loading a resource to some extent - I see that makes sense, thank you. However the current implementation means that protocols like |
Rendering a link that's not actually doing anything when clicked is guaranteed to result in an equal number of questions, if not more. By definition a link has an action when clicked, so since we cannot provide an action in this case due to browser limitations there's no point in my opinion in rendering the link at all. In a custom deployment of PDF.js you can of course tweak this, but it's not something we support. |
How about other protocols like e.g. |
They are evaluated on a case-by-case basis. Given that Line 377 in 1e11f87
I don't immediately see an issue for whatsapp: .
|
I would like to keep this issue open. I understand that my initial solution (just allowing the file protocol) could lead to a degraded user experience as the links would not do anything. On the other hand however the issue is not fixed by any means and still represent a violation of the PDF spec. Furthermore this issue prevents links between local PDFs to work which are not too rare in larger documents. Therefore would I like to take a closer look at this and maybe even the original bug on the mozilla tracker regarding relative links and see if there may be an alternative solution which would work for both use cases. Maybe this bug should however be reported in the firefox bugtracker as it seems impossible to implement a fix in pdf.js alone and it would rather need changes in how firefox embeds pdf.js? |
The PDF.js viewer is purposely not supporting relative links, and that simply won't change, without There's (generally speaking) no problem generating an absolute URL even for a
The only solution would be if a |
I agree that something should be done about this. You can end up with hideously broken files like mwe.pdf if you open it locally on FF instead of on a PDF viewer, but if you open it with, say, the online LaTeX to generate the presentation
|
I opened a ticket at firefox bugzilla regarding the problem and briefly outlined the current problem, steps which are necessary, and behaviour of competitor products. |
link.pdf
Configuration:
Steps to reproduce the problem:
What is the expected behavior? (add screenshot)
What went wrong? (add screenshot)
LaTeX Code to generate the pdf
The text was updated successfully, but these errors were encountered: