mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 21:11:52 +00:00
The walk of the forms that content draws through its resources (`resource_ops`) decoded each one outside the page's decode allowance: up to 1 GiB a form, read again by each cleanup that walks them, on every page. The interpreter skips a form outside the marks, so for such a form this walk is the only read. `resource_ops` now charges the bytes it decodes to the `DecodeBudget` it is given. The content walk hands back what it left of the page's allowance (`Scope::into_budget`), and the cleanups after it spend that: the check of what the page still draws (`prune`), the properties and the Type 3 fonts, in Apply Redactions and in Remove Hidden Information. A rewritten form's cleanups spend the walk's allowance as they go. The unlinking pass's check of the properties, which walks every page that shares a resource dictionary, gives each page's content an allowance of its own. Only bytes are charged, not form entries: each cleanup reads the same forms again, so a page drawing many small forms would run out of entries having decoded little. Tests, each failing with the charge reverted, and the last three with their own part of it reverted (the hand-back on either page, the rewritten form's cleanups): - what_content_draws_through_its_resources_is_read_within_its_allowance (a 2,000-byte form read with 2,000 bytes left, refused with 1,999); - the_cleanups_after_the_content_walk_spend_what_it_left_of_the_pages_allowance; - the_cleanups_of_a_rewritten_form_spend_the_pages_allowance; - removing_hidden_text_spends_what_the_content_walk_left_of_the_pages_allowance. In each of the last three a form without resources of its own is read three times: refused at 100 MiB, more than the page's 256 MiB, and not at 50 MiB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY