Conversation
Member
juliusknorr
commented
Mar 17, 2020
- 2.2.228 is not feasible yet as it comes with a different CSP issues as it would require us to bundle it with regenerator-runtime (CSP violations for unsafe-inline in [email protected] mozilla/pdf.js#11036)
- I currently fail to get a proper webpack build up and running due to the dist packages of pdf.js only including parts of the viewer and mainly focussing on the library itself
The example PDF ("compressed.tracemonkey-pldi-09.pdf") is not needed and
thus was not included; "templates/viewer.php" acts as "viewer.html", so
the later was not included either.
On the other hand, source maps were kept so they could be used in case
of need.
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The "viewer.php" acts as the "viewer.html" file included in the PDF.js package. This commit updates "viewer.php" with the changes to "viewer.html" from PDF.js 1.9.426 to 2.0.943 while respecting the customized parts of "viewer.php" (like the close button or the "nonce" attribute). Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The PDFViewerApplication options are no longer got from the PDFJS object but from a helper object that holds the configuration. This object is globally set before "PDFViewerApplication.initialize" is called, so it can be used in the custom initialization code. Note that despite setting "isEvalSupported" to false this does not work out of the box with the default Nextcloud Content Security Policy. Due to how the PDF.js library is bundled it tries to execute an "eval" function, which is blocked by the CSP and causes the viewer to not load the PDF file. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
The example PDF ("compressed.tracemonkey-pldi-09.pdf") is not needed and
thus was not included; "templates/viewer.php" acts as "viewer.html", so
the later was not included either.
On the other hand, source maps were kept so they could be used in case
of need.
Note that "viewer.html" did not change between v2.0.943 and v2.1.266, so
there is no need to update "templates/viewer.php".
Also note that, unlike v2.0.943, PDF.js v2.1.266 works out of the box
with Nextcloud Content Security Policy.
Signed-off-by: Julius Härtl <[email protected]>
Since v2.1.266 an event is triggered before the PDFViewerApplication is initialized, so the hack that relied on the asynchronous calls during the initialization to hook in is no longer needed. However, as the event is triggered before the initialization the options are now set before the preferences are read. As the preferences override the options the preferences need to be disabled to be able to set "externalLinkTarget". Disabling the preferences has no effect for the rest of them, as they already have the same value as the default options. Signed-off-by: Daniel Calviño Sánchez <[email protected]>
824b04c to
85b9bdf
Compare
Member
|
I have fixed opening the links, loading the character maps, the missing close button and removed some unneeded files from the vendor folder. This should be good to go (but please test anyway ;-) ). As an additional note, like 2.2.228, 2.0.943 can not be used either due to the CSP. It seems that 2.1.266 happens to work due to some lucky combination of how the library code is initialized 🤷♂️ |
Member
|
/backport to stable18 |
Member
|
/backport to stable17 |
|
backport to stable18 in #169 |
|
backport to stable17 in #170 |
Member
|
/backport to stable16 |
|
backport to stable16 in #171 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.