Open
Conversation
PalmerAL
reviewed
Apr 12, 2026
Collaborator
PalmerAL
left a comment
There was a problem hiding this comment.
Sorry for the delay. This looks good to me aside from the couple of comments I've added.
Obviously the largest concern with this is security; I've read through it and I don't see any issues, but I'll review it one more time prior to merging.
| pdfjsLib.getDocument({ url: url, withCredentials: true }).promise.then(async function (_pdf) { | ||
| function requestLocalPDFData (fileURL) { | ||
| return new Promise(function (resolve, reject) { | ||
| var requestId = ++localPDFRequestId |
Collaborator
There was a problem hiding this comment.
localPDFRequestId is unique to each viewer instance, so it will be 0 in basically all cases. To create a unique request ID, you probably need to use Math.random() or similar.
| }) | ||
| } | ||
|
|
||
| function getPDFDocumentRequest (targetURL, requestLocalPDFData) { |
Collaborator
There was a problem hiding this comment.
I think this can just call the global requestLocalPDFData; it doesn't need to be an argument.
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.
FIxes #2375.
Tested only on MacOS 15.7.3
Changes
main/download.jsAdded IPC handler
readLocalPDFthat reads local PDF bytes in the main process.main/localPDFAccess.jsAdded centralized validation for local PDF access:
min://app/pages/pdfViewer/index.html...)file://js/preload/default.jsAdded bridge for
readLocalPDFrequests:window.postMessagefrom vieweripc.invoke('readLocalPDF')window.postMessagepages/pdfViewer/viewer.jsUpdated loading flow:
file://PDFs: load via byte data (getDocument({ data }))getDocument({ url, withCredentials: true }))pages/pdfViewer/documentRequest.mjsAdded helper for selecting local-vs-remote PDF.js request mode.
Security