mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-31 07:39:08 +00:00
A form XObject or annotation appearance with more `Q` than `q` popped graphics states saved by the content that drew it, so later page text, paint and clip lost the page's `cm` and clip, and search redaction of that text failed closed at `redact_apply`. A content stream balances its own `q` and `Q` (ISO 32000-2 §8.4.2, §8.10.1). Vendored hayro-interpret patch (68): `interpret()` records the state depth at which its stream starts (`Context::enter_stream`) and restores the outer floor on exit; a `Q` at the floor is ignored with a warning. Page content (`interpret_content`) is unchanged. Tests: pdfcraft-render `it::stray_q_in_a_form` (three behaviour tests fail with the fix reverted, one guard) and pdfcraft-automation `it::redact_after_stray_q_form` (end to end; fails at `redact_apply` with the fix reverted). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9