Ensure that the empty dictionary won't be accidentally modified, and slightly improve the "SaveDocument" handler in src/core/worker.js
#12375
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.
Ensure that the empty dictionary won't be accidentally modified
Currently there's nothing that prevents modification of the
Dict.empty
primitive, which obviously needs to be truly empty to prevent any future (hard to find) bugs.A couple of small improvements in the "SaveDocument" handler in
src/core/worker.js
Check that the "Info"-entry, in the XRef-trailer, is actually a dictionary before accessing it. This is similar to the
PDFDocument.documentInfo
method and follows the general principal of validating data carefully before accessing it, given how often PDF-software may create corrupt PDF files.Slightly simplify the "XFA"-lookup, since there's no point in trying to fetch something from the empty dictionary.