Skip to content

Conversation

@backportbot-nextcloud
Copy link

backport of #168

danxuliu and others added 5 commits March 18, 2020 14:17
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]>
@rullzer rullzer mentioned this pull request Apr 13, 2020
3 tasks
Copy link
Member

@danxuliu danxuliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works 👍

@rullzer rullzer merged commit 0ebe3a4 into stable16 Apr 14, 2020
@delete-merged-branch delete-merged-branch bot deleted the backport/168/stable16 branch April 14, 2020 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants