Skip to content
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

Fix PDF viewer failing on Edge (not based on Chromium) #297

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24,885 changes: 18,542 additions & 6,343 deletions js/pdfjs/build/pdf.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/build/pdf.js.map

Large diffs are not rendered by default.

28,036 changes: 20,152 additions & 7,884 deletions js/pdfjs/build/pdf.worker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/build/pdf.worker.js.map

Large diffs are not rendered by default.

16,435 changes: 9,720 additions & 6,715 deletions js/pdfjs/web/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/pdfjs/web/viewer.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function showPdfViewer(bool $minmode = false): TemplateResponse {
$policy->addAllowedChildSrcDomain('\'self\'');
$policy->addAllowedFontDomain('data:');
$policy->addAllowedImageDomain('*');
$policy->allowEvalScript(false);
// Needed for the ES5 compatible build of PDF.js
$policy->allowEvalScript(true);
$response->setContentSecurityPolicy($policy);

return $response;
Expand Down
2 changes: 1 addition & 1 deletion pdfjs-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ console.info('Fetching pdfjs', PDFJSversion)
const pdfjsProgress = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
pdfjsProgress.start(100, 0)

progress(request(`https://github.com/mozilla/pdf.js/releases/download/v${PDFJSversion}/pdfjs-${PDFJSversion}-dist.zip`), {
progress(request(`https://github.com/mozilla/pdf.js/releases/download/v${PDFJSversion}/pdfjs-${PDFJSversion}-es5-dist.zip`), {
throttle: 50,
delay: 0,
})
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Controller/DisplayControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testShowPdfViewer(): void {
$policy->addAllowedChildSrcDomain('\'self\'');
$policy->addAllowedFontDomain('data:');
$policy->addAllowedImageDomain('*');
$policy->allowEvalScript(false);
$policy->allowEvalScript(true);
$expectedResponse->setContentSecurityPolicy($policy);

$this->assertEquals($expectedResponse, $this->controller->showPdfViewer());
Expand Down