Skip to content

fix: aggregate startxref whitespace tolerance#3

Merged
vitormattos merged 4 commits into
fork/libresign-parser-fixesfrom
fix/unable-find-xref-pass-c
Apr 24, 2026
Merged

fix: aggregate startxref whitespace tolerance#3
vitormattos merged 4 commits into
fork/libresign-parser-fixesfrom
fix/unable-find-xref-pass-c

Conversation

@vitormattos
Copy link
Copy Markdown
Owner

Summary

  • Mirror of the upstream fix branch for startxref whitespace tolerance before xref.
  • Keeps LibreSign integration aligned while upstream review is in progress.

Upstream PR

Scope

  • Branch: fix/unable-find-xref-pass-c
  • Target aggregate branch: fork/libresign-parser-fixes

Some PDFs set startxref to the whitespace immediately before the
xref keyword instead of the first letter of xref.

The parser required an exact match and incorrectly switched to xref
stream decoding, which then failed with Invalid object reference.

Changes:
- Skip PDF whitespace before checking startxref position
- Use adjusted offset when decoding classic xref
- Apply same whitespace tolerance for Unix line-ending detection
- Tighten trailer key regexes to match /Size /Root /Encrypt /Info /Prev
- Add regression fixture and integration test

Regression fixture:
- samples/bugs/PullRequestXrefWhitespaceStart.pdf

Test:
- DocumentIssueFocusTest::testParseFileWhenStartxrefPointsToLeadingWhitespace

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos merged commit efdc509 into fork/libresign-parser-fixes Apr 24, 2026
34 checks passed
@vitormattos vitormattos deleted the fix/unable-find-xref-pass-c branch April 27, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant