Give each signature field a unique name - #384
Open
AlexanderV wants to merge 1 commit into
Open
Conversation
The partial name of the signature field was hard-coded to "Signature1" (with a TODO). Signing a document a second time therefore produced two fields named "Signature1". The fully qualified names of interactive form fields must be unique; validators like Acrobat either merge or reject the duplicate. The first unused "SignatureN" is now chosen by scanning the names of the fields at the root of the interactive form.
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.
The partial name of a signature field is hard-coded, with a TODO next to it (
DigitalSignatureHandler.cs):The answer to the TODO is yes: signing a document that already contains a signature produces a second field named
Signature1. The fully qualified names of interactive form fields must be unique; validators either merge the two fields or reject the file.The first unused
SignatureNis now chosen by scanning the names of the fields at the root of the interactive form. Only the root is relevant, because the new field is added there — the name of a field below the root is relative to the name of its parent and cannot collide with a root name.Tests (
Pdf.Signatures/SignatureFieldNameTests.cs, 3 cases): a new document getsSignature1; signing an already signed document getsSignature2; an unrelated field that already occupiesSignature1is respected.The tests use a dummy
IDigitalSignerand an empty appearance handler (Pdf.Signatures/TestSigner.cs), so they need no certificate, no assets and no network, and they run in milliseconds.Verified on top of current
master: fullPdfSharp.Testssuite green (255 passed, 0 failed).This PR is independent of my other PRs; each of them applies to
masteron its own.