-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Bug]: Adding a <base href>
tag to a page containing a pdfjs viewer breaks transparancy filters in Firefox.
#18406
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
Comments
Possible related issue: #16287 |
Not confident this is a good fix but adding the current url to the filters seams to work in my env:
|
Would this perhaps suggest that it's a general browser bug in Firefox, which should be reported (in Bugzilla) and fixed there instead of us having to work-around it in the PDF.js project?
Unfortunately that diff has a couple of issues:
|
As far as I understand, that's not a browser bug, but a peculiarity of SVG filters. @Hypercubed can tell you more about it. Thanks for detecting the issues you've mentioned! |
In that case all browsers ought to be similarly affected, which according #18406 (comment) doesn't appear to be the case!? |
FYI, in Firefox we removed the base element: |
@Snuffleupagus I can't really speak to why this impacts Firefox only. Seams like all browsers should be impacted the same; from what I understand of the SVG it sounds like Firefox is "doing the right thing". There are several google hits that specifically mention different behavior in Firefox... FWIW. As for the patch... yes that was just the first few lines. I tested replacing all Another idea I had was if the SVG rendering could be done in another document (using something like |
The smallest patch I could imagine, assuming that we actually want to attempt to fix this, would be something along these lines (with the functionality limited to GENERIC builds): master...Snuffleupagus:pdf.js:DOMFilterFactory-baseUrl
That sounds essentially like the following Lines 194 to 196 in 1bdd692
|
This comment was marked as resolved.
This comment was marked as resolved.
@Snuffleupagus I just saw your patch (missed it the first tiome reading your comment). What about
|
Please see: Lines 139 to 141 in 1bdd692
No, that's not appropriate since (as documented) it has a completely different purpose.
No, that parameter is user defined and can be any valid URL. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Given the above quote it's not expected to run anywhere else, so only The initial instance of SVG filter use came in PR #16062, which is well over a year ago, and this is the first time that we've seen the filter URLs cause issues in the general PDF.js library.
/cc @calixteman, @timvandermeij Any thoughts/opinions on how to proceed here? |
Option 3:
|
It showed up in stephanrauh/ngx-extended-pdf-viewer only after upgrading pdfjs past v4.2 (and only Firefox). It's a question of how many instances of PDFjs >4.2 are running in SPAs. Maybe not many so far... |
Could it be detected in using |
Yes, that should work as far as I understand. |
Attach (recommended) or Link to PDF file
https://github.com/mozilla/pdf.js/files/11229069/test.pdf
Web browser and its version
Firefox 127.0.2
Operating system and its version
Mac and Windows
PDF.js version
4.5 (master)
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
npx gulp server
<base href="." />
toviewer.html
What is the expected behavior?
The PDF should render the same regardless of
<base href>
What went wrong?
When rendering a pdf in Firefox when a
<base href>
is defined the drop shadow is not rendered correctly.Link to a viewer
No response
Additional context
This issue was discovered and discussed here: stephanrauh/ngx-extended-pdf-viewer#2363
We tested accross multiple browsers, OSs, sites, and PDFs. The issue was eventually narrowed down to pdfjs v4.3-v4.5 in Firefox when the site defines a
<base href>
. Many SPAs require a base href to be defined. This issue was not seen in other browsers nor in pdfjs v.4.2. It was seen in Firefox regardless of OS.Additional note: Relatively certain this issue is SVG IRI references in
display_utils.js
.The text was updated successfully, but these errors were encountered: