Commit Graph
6827 Commits
Author SHA1 Message Date
mtlcl410andClaude Opus 5.5 fe5fa9e908 fix(render): a number token the scanner can't read is skipped whole, so 1beginbfchar doesn't start mappings (hayro-postscript patch 2)
A number read stops at the first byte that can't be part of a number,
which may be inside the token: `parse_object_or_skip` then read the rest
(`beginbfchar` in `1beginbfchar`) as a token of its own, and the pairs
after it became mappings. The rest of the token is now skipped with the
failed number, one failure per token, as PostScript reads a run of
regular characters as one token.

The render test's run of unreadable tokens before the mappings is spaced:
a run of `-` with nothing between them is one token now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 08:26:11 +08:00
mtlcl410 ac30985c96 Merge remote-tracking branch 'upstream/main' into fix/pdfa-transparency-group 2026-11-07 08:21:11 +08:00
Helen Kwok a9e98e0db6 pdfcraft-web: window.pdfcraft, the page command API from craft-web-api, opt-in with ?control
?control attaches the UI control channel (the one --control serves) and installs window.pdfcraft: request, execute (ui.command), commands (ui.commands), docInspect (ui.state), uiInspect (ui.inspect) and screenshot. The channel keeps the accessibility tree of every frame, so it stays off unless the page asks. Opening, saving, the file name and the unsaved flag stay with the host messages.
2026-11-07 08:17:43 +08:00
mtlcl410andClaude Opus 5.5 07c5163b66 fix(render): every Adobe collection, Identity-V and /H over CFF read through their UCS2 CMap, other collections do not (hayro-interpret patch 84)
Tests for the UCS2 route of hayro-interpret patch 84: Adobe-GB1, -CNS1 and
-Korea1 fonts with Identity-H and no /ToUnicode (CFF and TrueType), each
with a CID-to-Unicode pair read from its bundled UCS2 CMap; Identity-V
and /H over a CFF program; and a Type 0 font of a non-Adobe collection,
which gets no text through this route. Each collection's case fails when
its family is pointed at another collection's UCS2 CMap, and the
non-Adobe case fails when such a family is given one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 07:28:02 +08:00
mtlcl410 592da72b0b Merge remote-tracking branch 'upstream/main' into fix/cjk-ucs2-text 2026-11-07 07:22:46 +08:00
mtlcl410andClaude Opus 5.5 734bff509a M5: a text markup's widened box stops at the crop box and the quad cap; the edit path saves it (view.render-annotation-appearances)
- The widened appearance box and /Rect reach the /QuadPoints only as far
  as the page's visible region (crop box within media box, ISO 32000-2
  §14.11.2), never shrink /Rect, and are not widened at all by quads
  wholly off the page or by more than MAX_MARKUP_QUADS (10,000)
  quadrilaterals (counted before the numbers are read).
- One /Rect normalisation (normalised_rect) for appearance_context and the
  reach; markup_reach takes the normalised /Rect and the page box, and
  apply_appearance takes the saved /Rect from the built /BBox
  (widened_rect) instead of computing the reach a second time.
- Tests: the restyle (set_appearance) path saves the widened /Rect, stops
  at the page and keeps a fitting /Rect as written; a markup with its own
  /AP and a non-markup subtype are not widened; crop box and cap cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 07:22:15 +08:00
mtlcl410andClaude Opus 5.5 49f200f99d M2: a non-embedded Times New Roman draws the glyphs its codes name (hayro-interpret patch 88)
A Times New Roman the PDF doesn't embed, written as a Type 0 font with a
CIDFontType2 descendant (TimesNewRoman,Bold, TimesNewRomanPSMT and the
other faces) and no /ToUnicode, now goes through the rule of patch (76):
each CID gives, through /CIDToGIDMap (ISO 32000-2 Table 115), a glyph
index in the author's font, and the substitute draws that glyph by its
name in the standard Macintosh order of the TrueType post table. Before,
the CID was taken as one of the substitute's own glyph indexes, which
ISO 32000-2 9.7.4.2 notes "are not defined consistently from one font to
another", and the ameli.fr mutation form drew "Salarié(e) du régime
général" as "Salari²*g+f w't²i lo g'ì²p²tcn".

Times New Roman numbers its first 258 glyphs in that order: the same
form's embedded Times New Roman subsets keep their glyph indexes, and 941
of their 942 /ToUnicode entries below 258 name that order's character.
Times and Times New Roman MT Std are other fonts and keep the old path.

Fixes #6449

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 07:09:33 +08:00
mtlcl410 c1cd0e32cd Merge remote-tracking branch 'upstream/main' into fix/markup-quads-outside-rect 2026-11-07 07:09:26 +08:00
mtlcl410andClaude Opus 5.5 4bba22a122 M2: strokes, fast rectangles and layer clips past the rasterizer's coverage are left out too (view.render-error-isolation)
Each of the dispatcher's other room checks gets a case: a page whose only
coverage is strokes, or axis-aligned rectangles, drawn 2^10 times through
forms, then a red marker through the same path, rendered with the
rasterizer kept to 200,000 values (the marker is left out and the page
says so; unlimited, it is drawn), and clipped layers pushed through
vello_cpu's RenderContext directly (hayro pushes no clipped layers). Each
case fails with only its own path's check removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 07:08:53 +08:00
mtlcl410 546a808e1a Merge remote-tracking branch 'upstream/main' into fix/non-embedded-times-new-roman-6449 2026-11-07 07:03:16 +08:00
mtlcl410 078acbc593 Merge remote-tracking branch 'upstream/main' into fix/form-fanout-budget 2026-11-07 07:03:01 +08:00
mtlcl410andClaude Opus 5.5 1d968fea8f M2: patterned stencil and tiling cell tests count offscreen draws instead of timing them; interleaved settings and uncoloured patterns keep their own cells
hayro patch (30) gains a test hook, `offscreen_draws`: per thread, the tiling cells drawn
and the pixels of every pixmap drawn offscreen, all made by `offscreen_pixmap`. The two
wall-clock bounds become counts: 5,000 patterned stencils draw one cell and less than a page
of pixels offscreen, and 3,000 fills of one setting draw one cell. New tests interleave the
settings of two coloured patterns with cells of one size and one of them at two scales, each
showing its own pattern in place and drawing one cell per setting, and paint an uncoloured
pattern in two colours and, at half opacity, both as a fill and as a stencil mask's copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-07 07:01:42 +08:00
mtlcl410andClaude Opus 5.5 1820ba241e M11: PDF/A verify says where each XMP extension schema finding is (optimize.pdfa-validate)
6.6.2.3.3 findings are now reported per description instead of once per
entry name: each names the schema by its pdfaSchema:namespaceURI (or #n),
the property, value type or field by its own name (a field as type/name),
and the metadata stream, with Issue::object set. A misused prefix names
the namespace URI and the prefix written (or that none was); a container
that isn't one rdf:Bag names what it holds instead. Findings are capped at
1000 per document and repeated names at 200 characters.

6.6.2.3.1 issues now name the type the XMP Specification gives the
property, as the specification writes it (Integer, seq Rational,
Lang Alt, Flash); structure types carry their names for this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 06:53:21 +08:00
mtlcl410andClaude Opus 5.5 0647a4e724 fix(render): an unreadable CMap token counts once against the skip limit, with unit tests (hayro-cmap patch 3, hayro-postscript patch 2)
- `Scanner::parse_object_or_skip` skips whitespace and comments before
  taking its start offset, so a token after a space fails once, not
  twice, whoever calls it. (The CMap scan already skipped whitespace in
  `at_end`, so CMap results do not change.)
- Unit tests in hayro-postscript (stepping over a token, a failed read
  not read again, never past the end of the data) and in hayro-cmap
  (bfchar and bfrange after a stray `>` or a spaced name, the 1,024-token
  limit at its boundary, a CMap of unreadable tokens only failing).
- The render test checks a bfrange entry after the bad token, a run past
  the limit before the mappings, and a CMap of unreadable tokens only;
  its wall-clock assertion is gone, the no-re-read property is the
  deterministic hayro-postscript test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 06:52:15 +08:00
mtlcl410 f5d3841823 Merge remote-tracking branch 'upstream/main' into fix/render-patterned-stencils-share-cells 2026-11-07 06:48:24 +08:00
mtlcl410 00f24531dd Merge branch 'fix/pdfa-xmp-exif-types' into fix/pdfa-xmp-extension-schemas
# Conflicts:
#	crates/preflight/src/lib.rs
#	crates/preflight/src/tests.rs
#	crates/preflight/src/xmp_types.rs
#	parity/acrobat-features.toml
2026-11-07 06:46:52 +08:00
mtlcl410 23ed9c6df9 Merge remote-tracking branch 'upstream/main' into fix/pdfa-xmp-extension-schemas 2026-11-07 06:46:13 +08:00
mtlcl410andClaude Opus 5.5 173cfa5390 M11: PDF/A verify names the metadata stream of a mistyped XMP property (optimize.pdfa-validate)
A 6.6.2.3.1 issue now says which metadata stream holds the property
("in metadata stream 5 0 R") and carries its ObjRef in Issue::object, so a
property mistyped in more than one stream is reported once per stream.
Wordings that name more than one thing use named holes, such as {object},
filled in one pass with the {} value, so a translation can reorder them.

Tests: the stream is named and located per issue; a non-preferred prefix
bound to the TIFF, EXIF or aux namespace URI is checked, and the preferred
prefixes bound to other URIs are not, proving the lookup is by URI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 06:46:03 +08:00
mtlcl410 46ed507680 Merge remote-tracking branch 'upstream/main' into fix/cmap-skip-unreadable-tokens 2026-11-07 06:43:15 +08:00
mtlcl410andClaude Opus 5.5 3b47f80575 test: a bf entry wins over a CID entry for the same /ToUnicode code (create.text-extraction)
A `/ToUnicode` that gives one code both a `beginbfchar` / `beginbfrange`
entry and a `begincidchar` / `begincidrange` entry extracts the bf value
(ISO 32000-2 §9.10.3); the CID number is read only for codes no bf entry
covers. The case is checked with two-byte and one-byte entries: with
two-byte entries the CID lookup already falls back to bf entries at its
one-byte step, so the one-byte case is the one that fails if the CID
entries are read first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 06:42:54 +08:00
mtlcl410 8bbe2cdd46 Merge remote-tracking branch 'upstream/main' into fix/pdfa-xmp-exif-types 2026-11-07 06:37:28 +08:00
mtlcl410 4e49bfa8eb Merge remote-tracking branch 'upstream/main' into fix/tounicode-cidrange-text 2026-11-07 06:37:23 +08:00
Zinadin Zidan 2153da0644 Add text: a stored ink is read without copying a long array (review)
Reading an item's /CMYK resolved the value, which copied a direct array,
then collected every entry before checking there were four. A file with a
huge numeric /CMYK paid for that on each content listing and item lookup.
Now a direct value is read where it is, a reference is followed without a
copy, and the array's length is checked before any entry is read. /Gray is
read the same way. A long /CMYK, direct or by reference, and a /Gray that is
a long array still read as no ink.
2026-11-07 03:06:01 +06:00
Zinadin Zidan c44896df95 Add text: an ink is read only from numbers and kept as painted (review)
A stored /CMYK with a non-numeric entry was read from its numbers alone, so
[0 /Bad 0 0 1] became 100 K; a /Gray that isn't a number with a /CMYK beside
it fell through to the CMYK. Both now give no ink, and the text paints in
its /Color.

g and k are written to the thousandth, as rg is, so an ink set or read with
finer digits painted other than what the item, its stored /Gray or /CMYK and
content_list held. The ink is now kept as painted, with its look, when set
and when read back. RGB text is unchanged.
2026-11-07 02:08:46 +06:00
oracola91 d2974e1fa5 Type 3 pruning counts a page's appearances toward one operator total
When a page lists a Type 3 font, prune_type3_from_resources (#5197) adds the
operators of the page's annotation appearances without resources of their
own. Each appearance was checked against the 2,000,000 cap on its own, so
several under it could add up to far more, and the prune went on with a
total no other path allows.

The appearances now share the running total, and passing it refuses the
redaction with the same kind of error as the other caps.
2026-11-06 21:17:52 +02:00
Zinadin Zidan 7e8551e4bc Add text: gray or CMYK colour, painted with g or k (#6440)
page_add_text and content_update took only RGB, so text added to a CMYK
print file painted 0 0 0 rg, rich black on press. They now also take gray
(0 to 1) or cmyk ([c, m, y, k]), painted with g or k and kept in /PCAdded as
/Gray or /CMYK beside /Color, which holds the matching look. An ink applies
only while the colour still shows its look: picking another colour, also in
the Format panel, drops it for good. RGB text is written byte for byte as
before, and a stored ink that doesn't match its colour is ignored.
2026-11-07 01:01:33 +06:00
oracola91 6a56476a07 Remove Hidden Information unlinks images nothing draws
Delete Image takes only the Do out of the page, and Replace Image adds a
new name and leaves the old image listed. Remove Hidden Information only
pruned the names its own content pass replaced, so a deleted image stayed
in the page's resources and in the full-rewrite save.

Every run now unlinks the image and form XObjects that nothing draws from
the page-tree resource dictionaries that name them. A name stays when
anything drawing through the dictionary uses it with Do: the pages, their
annotations' appearances, and every form, tiling pattern, Type 3 glyph and
soft mask they reach, with /Resources of their own or not, since a name
those don't define is looked up in the page's. Going by name keeps more
than it must, never less. Each stream is read once against one decode
budget; a page or stream that won't decode, or a spent budget, leaves the
dictionary as it is. The page-tree walk is shared with unlink_doomed.
2026-11-06 20:30:25 +02:00
oracola91 18a4cd117e Combine and Insert bring only the bookmarks and attachments of the pages chosen
With a selection of a file's pages, Combine and Insert Pages from File
brought every bookmark title along, the ones whose page was left out
without a destination, and Combine brought every attachment.

Only the bookmarks that lead to a copied page, and those above them,
come along now, as Extract keeps them since #4041. Attachments belong to
the whole file: they come along with all of its pages only.
2026-11-06 20:11:40 +02:00
oracola91 ac8eb51464 Removed layers leave every optional-content configuration
Hidden layers took a removed layer out of the default configuration's
top-level ON, OFF, Order and Locked lists only. A sub-list of /Order, a
radio-button group (/RBGroups), a usage rule (/AS) and every alternate
configuration in /Configs still named it, so its dictionary, name
included, stayed in the full-rewrite save.

The removal now cleans all of these lists, through nested arrays, in the
default configuration and in every alternate one. A usage rule left with
no layer goes.
2026-11-06 20:03:14 +02:00
oracola91 89e6a86029 Hidden layers includes layers a View usage rule turns off
Hidden layers read only the default configuration's ON, OFF and
BaseState. A layer listed on there but turned off on screen by a usage
rule (/AS, ISO 32000-2, 8.11.4.4: the View event in the View category,
with the layer's /Usage /View /ViewState OFF) is hidden in viewers that
apply the rules, yet its content stayed.

Such a layer now counts as hidden. Rules that turn a layer on, or that
apply only when printing or exporting, leave it as the lists say, so the
removal never keeps less than it did.
2026-11-06 20:03:13 +02:00
Grzegorz MartensandClaude Opus 5.5 20e138fbf5 M8: tests pin the Type 3 cleanup's refusal of bytes it can't read
The Type 3 cleanup refuses a redaction when its scan of a page or form,
or its read of a kept glyph's program, meets bytes the parser can't
read. Nothing tested either refusal: cargo-mutants found both checks
could be dropped with every test passing, once 8bf63c879 moved them
after the loop.

unreadable_bytes_in_a_form_the_type3_cleanup_scans_refuse_the_redaction
leaves a string open in a form only that scan reads (resources of its
own, outside the mark), hiding the glyph the form shows after it, and
unreadable_bytes_in_a_kept_type3_glyph_program_refuse_the_redaction
leaves one open in the program of the glyph the page keeps, hiding the
image it draws. Each fails with its check disabled; with the checks off,
the glyph loses its program and the font its image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 18:11:07 +01:00
Grzegorz MartensandClaude Opus 5.5 8bf63c8792 M8: the Type 3 cleanup reads content and glyph programs one operator at a time
The Type 3 cleanup at the end of a redaction (unlink_type3) scans every
page and every form it reaches for the glyphs they show, and reads the
programs of the glyphs it keeps for the resources they use. Both parsed
each stream whole before checking for bytes they couldn't read, outside
the page's allowance and up to 1 GiB a stream. So a form with resources
of its own outside the mark, which no other reader follows, cost about
79 bytes of memory per byte of content: the peak grew by 632 MiB for
8 MiB of `n` operators. On main too, wherever a Type 3 font survives in
a page's or a form's resources.

Both now read with pdfcraft_content::ops, one operator at a time, and
refuse for unreadable bytes once they have read the whole stream, as
before. The scan only reads, and either error refuses the whole
operation, so acting on operators before that check changes nothing.

The memory test gains a case for each:
the_forms_followed_through_resources_are_read_one_operator_at_a_time
fails with either read reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 17:47:19 +01:00
Grzegorz MartensandClaude Opus 5.5 8e593d33a6 M8: the walk reads the forms it enters with /DecodeParms by reference
The walk read a form it enters, one whose box crosses a mark, with
DecodeBudget::decode_strict, which reads /DecodeParms only when direct.
Behind a predictor whose parameters are an indirect object, the form
read as the predictor's tag bytes and row differences. The walk found
nothing under the mark in it and left it as it was, still drawing what
lay under the mark: on main, text there stayed, and so did an image
only the form drew. Once the page's check read such a form with its
parameters (f227d63ab), an image leaked too when the page drew it under
the mark as well: the check saw the form draw it and kept the page's
name for it, where before it took the name away.

The walk now reads its forms through Document::with_direct_parms, as
the cleanups after it do. The page's own streams, and the redaction
proof's reads (verify/util.rs), still take /DecodeParms only when
direct, as on main; #6289 changes the page's.

Test what_a_form_with_parameters_by_reference_draws_under_the_mark_is_removed,
with text, and with an image drawn under the mark by the page and the
form and by the form alone, fails with the read reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 17:46:56 +01:00
mtlcl410 3b8c0aeaff Merge remote-tracking branch 'upstream/main' into pr-2137
# Conflicts:
#	crates/automation/tests/it/automation.rs
2026-11-07 00:41:35 +08:00
Grzegorz MartensandClaude Opus 5.5 2976caeb32 M8: the forms redaction follows through resources are read one operator at a time
resource_ops parsed the content and each form it follows whole before
checking its 2,000,000-operator limit, and content_draws parsed whole
streams with no limit at all. A parsed operator takes about 120 bytes,
and a form of `n` operators outside the mark cost 78 to 138 bytes of
memory per byte of content. Measured as the growth of the process's
peak: 629 MiB at 8 MiB, 1,253 MiB at 16 MiB and 4,415 MiB at 32 MiB, so
tens of GiB at the 256 MiB the page's allowance admits, from a file of
a few hundred KiB. The page's check of what it still
draws (prune), added in this branch, reads such forms on pages with no
fonts or properties too. On main the font and property cleanups read
them, and the unlinking check (content_draws) on any page that shares a
dictionary with a removed image, so the content_draws half fixes what
main does too.

Both now read with pdfcraft_content::ops, one operator at a time.
resource_ops holds at most one past its limit, and content_draws holds
no operators, as it only looks for Do. Measured as the peak resident memory of
the whole process (dev profile): the page's check over a form of 8, 16
and 64 MiB of `n` takes 311, 327 and 422 MiB, and the unlinking check
over one of 16 MiB takes 69 MiB, against 1,269 before (2,527 MiB at
32 MiB).

This bounds the operators held, not their operands: the parser still
holds the operands that no operator ends, so content of operands alone
costs about 30 bytes per byte (974 MiB for 32 MiB of `0`). Bounding
those is pdfcraft-content's, for every reader of content.

It also drops resource_ops' check that it followed no more than
2,000,000 forms. Each form it follows is a Do among the operators it
holds, which the operator limit already bounds, so that check could
never fail; cargo-mutants found it untested.

Test the_forms_followed_through_resources_are_read_one_operator_at_a_time
(tests/operator_memory.rs, a binary of its own) measures how much the
process's peak grows over 32 MiB of `n` operators through each check, on
Linux, and fails with either read reverted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 17:24:56 +01:00
mtlcl410andClaude Opus 5.5 1ad2638460 M1: a numbered glyph name shown at its own code reads as that code's character (create.text-extraction)
A simple Type 1 font without /ToUnicode whose glyphs are named only by a
number (`C39`, `C0032`, `MT72`, `G49`, as Windows printer drivers name
subset glyphs) extracted no text at all. ISO 32000-2 §9.10.2 gives such a
name no route to Unicode and leaves the reader to choose; pdftotext, PDFium
and MuPDF all read a glyph whose name's number (decimal or hexadecimal) is
the very code it is shown with as that code's Latin-1 character.

PdfCraft now does the same, and only then: a number naming another code
(`/C1` at 233, the counterexample on #3239) and control characters still
read as nothing, so the StandardEncoding guess #3239 removed stays out.

On the PDFBox JIRA attachments flagged for a text count far from
pdftotext's, three files (two Cnn built-in encodings, one Gxx hex /Differences)
now extract their full text, matching pdftotext and MuPDF.

Test: text::tests::numbered_glyph_names_read_as_their_own_code (fails with
the fallback reverted); glyph_names_outside_the_glyph_list_still_read_as_text
now expects `C39` at 39 and `C174` at 174 to read as `'` and `®`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 23:46:36 +08:00
Grzegorz MartensandClaude Opus 5.5 e08efe540a M8: a test pins a rewritten form's cleanups to the page's allowance on their own
the_cleanups_of_a_rewritten_form_spend_the_pages_allowance passed with
prune_form_resources doing nothing (cargo-mutants). The rewritten form
then kept its caller's resources unchanged, had none of its own, and the
page's check read the large form a third time through it. The rewritten
form now has resources of its own, which the page's cleanups don't
follow, so the three reads are the walk's and the rewritten form's two
cleanups'. It fails with prune_form_resources doing nothing, and with
each of the rewritten form's cleanups given an allowance of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 16:00:49 +01:00
Grzegorz MartensandClaude Opus 5.5 9657f0451b M8: a page installs its rewritten XObjects before checking what it still draws
On a page, the check of which names the rewritten content still draws
(`prune`) ran before the rewritten XObjects were added to the page's
/XObject dictionary, so it couldn't follow a rewritten form under its
new name. A rewritten form without resources of its own gets a copy of
the page's, pruned to what it draws, and draws through that. It keeps
none of its own only when the copy loses nothing, which takes a form
that draws itself, here outside the mark. Such a form draws through the
page's resources, and the page lost the names it draws there: the
original form, and an image under the mark that it draws again outside
it through an unchanged form.

The page now installs them first, as a rewritten form does with the
forms it rewrites. Remove Hidden Information's page does the same. There
every form is entered, so a form that draws itself is followed to the
depth limit and every copy above it keeps resources of its own (measured
with such a form); its order changes so that the two read alike.

Test an_image_a_rewritten_form_draws_again_through_the_pages_resources_is_kept
fails with Apply Redactions' old order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 15:51:12 +01:00
Grzegorz MartensandClaude Opus 5.5 6eabed25ca M8: the forms redaction follows through resources spend the page's allowance
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
2026-11-06 15:51:12 +01:00
Grzegorz MartensandClaude Opus 5.5 f227d63ab1 M8: redaction reads the forms and glyphs it follows with /DecodeParms by reference
To tell which resources content still draws, redaction reads the forms
it follows, and the Type 3 glyph programs, with `Stream::decoded`, which
reads `/DecodeParms` only when direct. Behind a predictor whose
parameters are an indirect object, a form read as the predictor's tag
bytes and row differences instead of its operators. So:

- the check of what a page still draws (`resource_ops`), the unlinking
  check (`content_draws`) and the unlinking from surviving forms'
  resources (`unlink_from_forms`) didn't see such a form draw an image
  again, and the image went from resources it is still drawn through;
- the Type 3 cleanup didn't see such a form, drawn or not, show a glyph,
  and dropped the glyph's program;
- it refused the redaction over a glyph program behind such a predictor,
  which it couldn't parse.

All six reads now go through `Document::with_direct_parms`. Each has a
test, the form or glyph behind a predictor whose parameters are given by
reference, that fails with that read reverted:
- an_image_a_form_with_parameters_by_reference_draws_again_is_kept
  (`resource_ops` and `content_draws`);
- an_image_a_surviving_form_with_parameters_by_reference_draws_is_kept;
- a_type3_glyph_a_form_with_parameters_by_reference_shows_is_kept;
- a_type3_glyph_an_undrawn_form_with_parameters_by_reference_shows_is_kept;
- an_image_a_type3_glyph_with_parameters_by_reference_draws_is_kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 15:50:40 +01:00
Grzegorz MartensandClaude Opus 5.5 ea51451efc M8: tests pin which forms redaction follows and where its walk stops
A form with resources of its own draws through those, so neither check
of what is still drawn may follow it: the page's (prune) and the
unlinking one at the end of a redaction (content_draws). Nothing pinned
either. A test now has a form on another page naming a different image
the same way, and the redacted image still leaves the dictionary both
pages inherit, which pins the unlinking check. Another calls the page's
check directly with such a form, since in a whole redaction the
unlinking check would drop the name anyway.

The walk of what content draws through its resources refuses content
of more than 2,000,000 operators, counting those of the forms it
follows. A test now pins that boundary for both counts.

Remove Hidden Information keeps a name that a form without resources,
left as it was, still draws, as Apply Redactions does. A test now pins
that with hidden text, which a form loses or keeps depending on where
it is drawn.

The doc comment of prune now says when it refuses, with examples of
what Stream::decoded refuses, and that corrupt data in such a form is
read up to the damage, which may be nothing, not refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 15:50:40 +01:00
Grzegorz MartensandClaude Opus 5.5 8c06f7a3eb M8: a form whose /Resources is null draws through its caller's when redaction unlinks
A form whose /Resources is null, or a reference to an object that isn't
there, has no resources of its own. The interpreter, the walk the
cleanup uses and the Type 3 cleanup all take it so. `content_draws` took
it as having its own. It decides at the end of a redaction whether a
removed image is still drawn through a page's or a surviving form's
resources, so it dropped the name the page had just kept for such a
form, and the form drew nothing there.

The page's check refuses a page whose content it can't read in full.
That includes bytes the parser can't read in a stream the redaction
leaves as it was, for Remove Hidden Information as for Apply
Redactions. Tests now pin that, and the error no longer calls the
content "property resources".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 15:50:40 +01:00
Grzegorz MartensandClaude Opus 5.5 7b1301b34f M8: redaction keeps an image a form without resources still draws
When a redaction removes or replaces an image or form under a mark, it
takes the name out of the page's resources unless the page still draws
it. It looked only at the page's own `Do` operators. A form with no
/Resources of its own draws through the page's, so when such a form
outside the mark drew the same image, the page lost the name and the
form drew nothing there.

The page now keeps a name that a form drawing through its resources
still draws, found as the cleanup of the fonts and properties these
forms use already finds them. As that cleanup does, it refuses the page
when such a form can't be read. On a page with fonts or properties to
clean up that was already the case; on a page with neither, the name
used to go.

A rewritten form had the same fault one level down. It dropped the names
it replaced before `prune_form_resources` ran. That function already
keeps what a form drawing through these resources still draws, so the
rewritten form now leaves the decision to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
2026-11-06 15:50:40 +01:00
alehel 513b0fae60 Merge remote-tracking branch 'origin/main' into refactor/page-press-edit-text
# Conflicts:
#	CLAUDE.md
2026-11-06 15:04:17 +01:00
mtlcl410andClaude Opus 5.5 0e75ad08c8 M2: a page past the rasterizer's coverage renders what fitted instead of failing (view.render-error-isolation)
vello_cpu keeps every path's coverage (alpha) values in one buffer until
the scene is rasterized, and a strip packs its index into that buffer in
31 bits; Strip::new asserts it fits. A page that painted one form 2^22
times over (22 nested forms, each drawing the next twice) grew the
buffer past 2^31 values at about 7 GB and panicked, and the page failed.

- vello_common (2): StripStorage::room_for_path{,_within} says whether
  one more path's coverage, at most the whole surface counted twice,
  still fits below that limit or a smaller one.
- vello_cpu (1): the single-threaded dispatcher leaves out fills,
  strokes, fast rectangles and layer clips once there is no room,
  records it (RenderContext::coverage_full) and can be kept to fewer
  values (set_max_coverage).
- hayro (31): RenderSettings::max_coverage passes that limit down, and
  a page whose paths were left out reports
  InterpreterWarning::ContentTruncated, which PdfCraft already shows as
  content skipped past the page's safety budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
2026-11-06 22:03:27 +08:00
FredApps f42fda7342 Merge pull request #6416 from storytold/house-rules
Copy the shared house rules into AGENTS.md
2026-11-06 14:58:52 +01:00
dc5cb122db trust certificate key type when CNG algorithm group is unreadable (#6391)
* trust certificate key type when CNG algorithm group is unreadable

When the algorithm group can't be read from the key store due to a provider bug, the certificate should not be rejected: its SubjectPublicKeyInfo already states the key type, and a real mismatch will surface at signing time instead of at enumeration.

Change matches_key to fall back to Ok(()) when key.algorithm_group() returns an error, trusting the certificate's key type; extract the group comparison into key_group_matches(group: Option<&AlgorithmGroup>, want: StoreKey) so the fallback and mismatch cases can be unit tested without a live CNG key.

Test: key_group_matches_trusts_when_group_unreadable failed before the change and passes after.

* Sign: back to LF line endings, shorter test comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 13:23:18 +01:00
1d71d6039f Add PCX image support to Create PDF conversion (#6396)
* Add PCX image support to Create PDF conversion

PCX is listed as an accepted Create source elsewhere but PdfCraft rejects it, so users cannot convert PCX images to PDF.

Detect PCX by its header in is_image and decode it in embed, adding pcx to CONVERTIBLE so existing from_images and source_kind paths handle it.

Test: pcx_images_become_pages failed before the change and passes after.

* Create: PCX scanlines hold every plane's row, 8-bit indexed images, older versions, standard test files

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 13:16:36 +01:00
mtlcl410 4608ee42a1 Merge remote-tracking branch 'upstream/main' into pr-2539
# Conflicts:
#	Cargo.lock
#	crates/redact/Cargo.toml
#	crates/redact/src/interp.rs
#	crates/redact/src/lib.rs
2026-11-06 19:57:08 +08:00
KenM76andClaude Opus 5.5 cf3ee49fbc Merge origin/main
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
2026-11-06 06:54:33 -05:00