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

[Zimit] App loads malformed PDFs when the PDF is loaded via an HTML redirect #413

Closed
Jaifroid opened this issue May 28, 2023 · 1 comment
Assignees
Labels
bug experimental Experimental features fixed Fixed, awaiting publication in new apps zimit
Milestone

Comments

@Jaifroid
Copy link
Member

Jaifroid commented May 28, 2023

Due to the blocking of PDF loading in sandboxed iframes in Chromium (see kiwix/libkiwix#916 and kiwix/libkiwix#948), I had originally introduced a workaround consisting of parsing anchors. As a side-effect of economizing code with a similar routine used in jQuery mode, this used a custom download routine, but that download routine is incapable of dealing with the fact that, anomalously, some Zimit archives store PDFs indirectly: when you attempt to load a PDF file, instead you get an HTML redirect to the PDF file. The custom download routine then serves the HTML as a blob with PDF headers... Which of course doesn't work.

The fix is twofold:

  • In SW mode, we should use the simpler code I discovered for Kiwix JS, which doesn't parse every link but merely intercepts a click on the iframe, inspects it, and sends the content to a new window. The browser then handles the redirect transparently.
  • In jQuery mode (Zimit ZIMs like www.ready.gov can be opened even in Internet Explorer, as the underlying Web site is designed to be readable in all browsers), we will have to handle this anomalous situation, because we are forced to download PDFs "manually". NB This part is not related to sandbox blocking, it is the download method itself that is incapable of dealing with PDFs served as HTML redirects (not something I could have foreseen...).

This issue mostly affects Zimit archives, though it could conceivably affect other archives as well, if a PDF is legitimately stored via a redirect that is not a standard dirEntry redirect.

@Jaifroid Jaifroid added bug experimental Experimental features zimit labels May 28, 2023
@Jaifroid Jaifroid added this to the Release 2.5.0 milestone May 28, 2023
@Jaifroid Jaifroid self-assigned this May 28, 2023
@Jaifroid
Copy link
Member Author

This should be fixed with 794b1e6, efbf267 and 7e7cf4b. I'm keeping open while testing.

@Jaifroid Jaifroid added the fixed Fixed, awaiting publication in new apps label May 30, 2023
@Jaifroid Jaifroid closed this as completed Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug experimental Experimental features fixed Fixed, awaiting publication in new apps zimit
Projects
None yet
Development

No branches or pull requests

1 participant