feat: document-sanitization EPDF_* exports (XMP, thumbnails, JavaScript)#27
Open
Phauks wants to merge 1 commit into
Open
feat: document-sanitization EPDF_* exports (XMP, thumbnails, JavaScript)#27Phauks wants to merge 1 commit into
Phauks wants to merge 1 commit into
Conversation
Add three EmbedPDF extension functions for redaction-defensibility scrubbing of non-content hidden vectors, mirroring the existing EPDF_SetMetaText style: - EPDF_RemoveXMPMetadata: drop the catalog /Metadata XMP stream (survives an Info-dict clear — the embedpdf#1 sanitization miss). - EPDF_RemoveEmbeddedThumbnails: drop every page /Thumb. - EPDF_RemoveAllJavaScript: drop /Names /JavaScript, JS /OpenAction, and /AA. Declared in public/fpdf_doc.h (auto-exported by the WASM build's generator), implemented in fpdfsdk/fpdf_doc.cpp via GetMutableRoot()/RemoveFor.
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.
Implements the engine (C++) side of embedpdf/embed-pdf-viewer#673 — document-sanitization removal functions for redaction defensibility.
Adds three
EPDF_*extension functions, mirroring the existingEPDF_SetMetaTextstyle (declared inpublic/fpdf_doc.h, implemented infpdfsdk/), so the WASM build's export generator picks them up automatically:EPDF_RemoveXMPMetadata(doc)— removes the catalog/Metadata(XMP) stream. XMP is stored separately from/Info, so clearing the Info dict leaves author/title/history in XMP; this removes it.EPDF_RemoveEmbeddedThumbnails(doc)— removes every page's/Thumb(can retain a pre-redaction page image).EPDF_RemoveAllJavaScript(doc)— removes the catalog/Names /JavaScriptname tree, a JavaScript/OpenAction(a plain GoTo/OpenActionis preserved), and the catalog/AA.Each uses the same
CPDFDocumentFromFPDFDocument+GetMutableRoot()/RemoveFor(andGetMutablePageDictionaryfor thumbnails) patterns as the neighbouring extensions.The TypeScript
sanitizeDocument(doc, options)engine method that composes these (plus the existingremoveAttachmentloop and a non-incremental save), along with Node tests asserting each vector is removed while unrelated content is preserved, are in a companion PR onembedpdf/embed-pdf-viewer(which bumps thepdfium-srcsubmodule to this commit once merged).Open questions for maintainers are in #673 (granular exports vs. a single
EPDF_SanitizeDocument; and treating hidden OCG layers as a separate follow-up).