The walk queued every entry of a Kids array before checking the node
limit, and resolving a direct node or array deep-copied it (two to four
times for a direct tree). It now recurses (depth stays capped at 32),
borrowing each node from its resolved owner, and stops at the limit as
it goes: only the branch being walked is held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
The stand-in fitting of hayro-interpret patch (67) also applies to Symbol
and ZapfDingbats (ISO 32000-2 9.6.2.2, Annex D.5 and D.6). Tests show
that their glyphs, and the check mark a check box draws for its /MK /CA
caption 4, keep the standard advance:
- symbol_dingbats_width (pdfcraft-render tests/it): Symbol alpha, beta,
pi, Sigma, Omega, Delta, infinity, bullet and plus, and ZapfDingbats
a20, a19, a23, a24, a71, a73, a77 and a28, drawn with no /Encoding:
each glyph's ink lies within its standard advance and fills most of
it, and the next glyph starts one standard advance on.
- dingbat_check_box (pdfcraft-engine tests/it): a check box with no /AP,
/DA (/ZaDb 60 Tf 0 g) and /MK /CA (4) draws its check centred in the
box, within its 846-unit advance and not squeezed.
The patch is renumbered (67), next after main's highest (66), and the
Tests column lists the new tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A standard 14 font named without /Widths is drawn with a bundled CFF
stand-in. Its glyphs are fitted to the standard metrics only when the
stand-in's own advance is known, and for the CFF stand-ins it never was,
so each glyph was drawn at its own width. The stand-ins' Euro is 667 to
722 units wide against the metrics' 556 (Helvetica) and 500 (Times), and
it overlapped the glyph after it ("€5", "€€", "a€b"). The advances
themselves were right: both the renderer's metrics and the writer's
Std14 table already give the Euro 556/500/600.
hayro-interpret patch (67): CffFontBlob::advance_width reads a glyph's
advance from its charstring, and StandardFontBlob uses it, so a stand-in
glyph is fitted to the standard width as the OpenType stand-ins already
were (ISO 32000-2 §9.6.2.2; Annex D Table D.2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The on-top trigger compared later paint with the paragraph's old box. A
rewrite that is moved (BlockStyle::offset), rewrapped wider or grown to
more lines can land under an image the old box is clear of, and stayed
underneath it. Both rewrite paths now test a Reach: the old box (where
the cover goes) plus the moved box grown to the wrap width either way
and down to the drawn line count (the widest measured line when wider), and
up by one line pitch for a larger size; turned text grows by the lines'
diagonal; any non-finite number makes it unbounded. Over-reaching is
harmless: the cover still fills only the old box. The parity notes say
so.
Tests: an_ocr_rewrite_goes_on_top_of_paint_over_where_it_lands (move,
width and line growth, both paths) and a_rewrites_reach_covers_its_move_
width_and_lines. Seen failing with each path reverted to the old box and
with growth zeroed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
`degenerate_fill_area` took a side under 1/256 unit as zero, so a thin
rectangle with area that the CTM scales up to whole pixels (100 x 1/1024
under a 4096x vertical scale covers four device rows) was clipped and
filled as a one-pixel band along its bounding-box diagonal. The fill
fallback had the same threshold and stroked it as a hairline. Both now
treat only an exactly zero side as degenerate; a box with area is
filled and clipped as the shape it is.
A slanted zero-height line less than a pixel high was snapped to its
whole bounding box, marking both rows along its full length when it
crossed a row boundary. Whole-pixel snapping is now used only when the
line stays within one device row or column (a line under 1/256 pixel
across is taken at its middle); otherwise it is the one-pixel band, so
each row is marked only where the line runs through it (ISO 32000-2
§10.7.4, half-open pixel squares the shape intersects).
Tests: crates/render/tests/it/zero_area_fill_clip.rs
a_thin_rectangle_scaled_up_to_whole_pixels_keeps_its_area and
a_slanted_zero_height_line_crossing_a_row_marks_each_row_only_where_it_runs
each fail with their part of the fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A rectangle with no height or no width encloses no area, so the
rasteriser marked nothing for it. As a clip (`10 10 100 0 re W n`) it
hid everything painted after it; as a fill it fell back to a
thinnest-line stroke that half-covered two rows when the line lay on a
pixel boundary.
ISO 32000-2 §10.7.4 paints every pixel whose half-open square the shape
intersects, "no matter how small the intersection is" ("A zero-width or
zero-height rectangle paints a line 1 pixel wide"), and a clipping
region is "the set of pixels that would be included by a fill
operation".
hayro-interpret patch (65), `degenerate_fill_area`: a fill or clip whose
path has no width or no height (but not both) gets the device pixels the
line touches - whole pixels when it runs along a device axis, a band one
device pixel wide when a rotated CTM turns it. Points, and paths with
area however thin, paint as before.
Tests: crates/render/tests/it/zero_area_fill_clip.rs (5 of 8 fail with
the patch reverted; 9 mutants of the patch each fail a test).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
main raised the redaction pass's form depth limit from 12 to 50 (#3645),
so the 16-deep chain was walked and the test's form was no longer removed
unread. The chain is now built from MAX_DEPTH, one level past it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Review on #2539: a removed glyph with no known text (no /ToUnicode, a
glyph name outside the list) went in as an empty string and nothing marked
the collection as incomplete, so when every removed glyph was like that
the terms were empty and /Info and XMP were left untouched. It now counts
as text the check couldn't keep, and every /Info string and XMP stream goes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review by Losminek on #2539:
- The work cap was checked per value, so very many small /Info or XMP
values could add up without bound. One budget now covers the whole
scrub; past it every further entry or packet counts as matching
(fail-closed). Identical removed runs are searched once.
- unescape looked for ';' through the rest of the text before checking
the 12-byte entity limit, so a packet of bare '&'s was quadratic. It
now looks only at the next 13 characters (200,000 '&': 943 ms -> 5 ms).
- A form XObject removed whole past the depth limit, or when its stream
doesn't decode, never had its text read; both paths now set
removed_cut so the metadata check clears everything instead of
searching incomplete text.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on #2539:
- only a processing instruction whose target is exactly `xpacket` is
skipped, so `<?xpacketAudit …?>` is searched like any other;
- an attribute name is kept across whitespace before `=`, so
`xmlns:x = "adobe:ns:meta/"` is still a declaration, not a value;
- the XMP stream is decoded with decoded_within(MAX_XMP_BYTES), so a small
stream that inflates hugely stops at the cap instead of after it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on #2539:
- the glyph end includes character and word spacing, so letter-spaced
redacted text is one word and still matches /Title (Bluefin);
- an XMP value wholly part of a removed run goes, as an /Info value does
(J. Li), compared as whole words (True stays with "untrue");
- when the removed text was cut short (too many runs, a run too long, too
many terms) every /Info string and XMP stream goes instead of searching
what was kept;
- XMP that is not valid UTF-8 or UTF-16 (also UTF-16 without a leading
mark) is not searched lossily but removed;
- namespace declarations and the xpacket wrapper are not searched;
comments and other processing instructions are;
- the raw-byte assertion saves without object streams so it can see /Info.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value shorter than the redacted sentence ("James Bond" from "JAMES BOND
IS A SPY") in a custom schema's element or attribute takes its packet
with it, as it goes from /Info, while a clean packet and an unrelated
entry stay. The regression #2598 suggested keeping whichever fix lands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An /Info value whose words are too short to be terms ("J. Li") survived
when the sentence holding it was redacted. A value that is wholly part
of a removed run, with three letters or digits at least, now goes as
well (the reverse check #2598 proposed).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applying redactions removed the glyphs under the marks but left the same
words in the document information dictionary and the XMP metadata.
The redaction interpreter now collects the removed glyphs' text in runs by
position. After verification, /Info entries containing a run (or one of its
longer words) are removed, and the catalog's and pages' XMP streams whose
text mentions one are removed whole; unreadable or oversized XMP fails
closed. Report::metadata counts what went.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UPDATE_APP (native builds; craft-update is a native-only dependency) carries our 128 px icon and accent (#b70228, its red, from the icon (#5245)). The updater, the self-update
helper and craft-update's startup prompt all get them through crate::UPDATE_APP; the
prompt draws the icon, the accent and "by ArtCraft" (craft-update's default developer).
craft-update is pinned to storytold/craft-libs main at 1065653e7 (#434).
Clippy fixes for Rust 1.99 in untouched code (same logic):
- crates/edit/src/images.rs
- crates/forms/src/appearance.rs
On a page with a word divided by a line-end hyphen, Find searches three
readings and merged their hits by dropping any hit that overlapped the
one kept before it. That also dropped hits of one reading that share a
glyph, such as "f" twice in an "ffi" ligature glyph, so the match count
depended on unrelated text elsewhere on the page. A hit is now left out
only where it overlaps one kept from another reading. The test oracle
follows the same rule, and a fixed case covers it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Find, text_find and Search & Redact's word search read the Latin
compatibility ligatures U+FB00-U+FB06 as their letters, in the page and in
the query, so "office" finds a page drawn with an fi ligature glyph
(ISO 32000-2 9.10.3 maps ligature glyphs to their letters). Each letter
stays owned by its glyph, so the highlight covers the ligature.
Where a line ends in a hyphen (U+002D, U+00AD, U+2010) between two
letters, the page is also searched with the hyphen and the break dropped
("example" finds "exam-" + "ple") and with the hyphen kept but the break
dropped ("exam-ple"). The hits are merged in page order; a match covers
both lines and is highlighted on each. Pages without such a hyphen are
searched once, as before.
Accent-insensitive search is left to the open pull request for #3460.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
An unrelated image later on the page no longer moves the paragraph and
its cover on top, where the cover could hide visible content inside the
paragraph's box. An XObject now counts only when it is drawn at or after
the paragraph and its visible box overlaps the paragraph's
(`images::painted_over`, from `page_images`). An inline image or a
shading after the paragraph still counts anywhere, and so does any XObject
when the page's images cannot be listed.
The trigger table now covers an image elsewhere, an image drawn first,
visible text, a filled path, a shading and an inline image. It fails with
the old any-`Do` trigger.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A picture read from the file is kept for the next place that links it.
Those kept bytes now count against MAX_TOTAL as well: past it, a name
not read yet is neither read nor kept, so a tree with many names holds
no more than the total however many names it has.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A table test for `revealed_under_paint`: only invisible text with an
XObject, inline image or shading after its place moves; a filled path,
visible text or nothing after it does not. Seen to fail with the check
reduced to `invisible`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
A flowed subform in a row cell is drawn at its column's width; its
content height is now measured at that width (less the cell's margins)
rather than at the width the cell gives itself, so content that wraps
in a narrower column no longer runs under the next row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
An OCR paragraph that may go on top of the page is checked (`check_on_top`)
before either rewrite path changes the document, so a page whose marked
content nests too deep is refused with nothing changed. `lift_on_top` no
longer checks.
Tests: undo restores the hidden layer and the scan, redo, save and reopen,
and a second edit of the moved text all show the edit; a phrase split from
visible text in the same text object shows its edit; a refused rewrite on a
too-deep page leaves the saved bytes unchanged. Each new test was seen to
fail with its part of the fix reverted.
Parity: the note says when the edit is drawn on top and lists what is
still missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
- A name-tree branch past the depth limit is skipped; the branches
beside it are still walked (before, the walk stopped there).
- Every place a picture is put counts against the pictures' total,
since each holds its own copy: one large picture used in many places
can no longer hold a copy per place without limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Some OCR tools write the invisible text layer first and the opaque page
image after it. Edit text rewrote such a phrase in the text's place, so
the cover and the new visible text were painted under the scan: the edit
was saved (text extraction finds it) but nothing showed.
When the rewritten paragraph was invisible and an XObject, inline image
or shading is painted after its place, the cover and the new text now go
on top of the page in their own q/Q (place_tagged, tagged Edited), drawn
from the initial graphics state with the paragraph's CTM. Only the state
the following text expects stays in place. Both rewrite paths (single
style and styled rows) do this. An OCR layer drawn over its scan, the
common case, is rewritten in place as before, so reading order is kept.
The test builds a scan whose OCR word comes before the image and checks
the cover and new text show, for one line and for a typed line break.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
- `zip`: 9.1.0 → 9.1.3
Requirement `roxmltree` 0.20 → 0.21: `ParsingOptions` gained `entity_resolver` (initializers take `..Default::default()`, i.e. none, as before) and is no longer `Copy` (two functions build it with a closure, the pattern merge.rs already used).
AGENTS.md (and CLAUDE.md where present) gets a CI workflows section: workflows only call
craft-common-actions at @main, with no other jobs; feature and fix PRs don't touch CI and
link or open a craft-common-actions issue (a PR only for a small fix that is safe for
every app and does not increase CI time); legacy jobs
aren't added to and move only as their own task, staying until a shared workflow runs them.
windows-arm64.yml moves from its SHA pin to @main. The pinned revision is on
craft-common-actions main and the workflow (and the actions it calls) is identical
there, so nothing changes in behaviour.
A template's <image href="…"> without inline data is now found in the
catalog's /Names /XFAImages tree, keyed by the URI the template writes
(XFA 3.3 pp. 257-258, "Storing Images Inside PDF"). Only that tree is
looked in; a link is never followed outside the file. The tree walk is
bounded (depth, nodes, names, a seen-set), and so are the bytes read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Attributes were told apart and written by prefixed name, so an inherited
q:kind whose prefix the element binds to another URI read back in the
element's namespace, and a same-named attribute in another namespace was
dropped. Attributes are now told apart by (URI, local name); one whose
prefix is bound to another URI on the merged element is written with a
fresh prefix declared there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
Bindings in scope were matched by prefix only, so an XHTML body's default
namespace inside the template's XFA default namespace was dropped and the
body read back in XFA's. Bindings are now kept as URI by prefix: a binding
is written when the URI differs from the one in scope, the nearest layer's
binding of a prefix wins, and an element in no namespace undeclares a
default namespace around it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
A SOM look-up cut short by its budget was cached as "not found", so later
references warned that they named nothing and the template was only partly
resolved. It now stops the expansion: the template is read unresolved with
one warning, as the README says.
Merging looked at every child of every prototype layer, also those that
write nothing (proto, unchosen ui/value alternatives), so a prototype with
many proto children used by many elements did quadratic work bounded only
by output. Merging now charges children, attributes and namespaces against
a 64 million budget before looking at them, and leaves out the skipped
classes before indexing them; namespace look-ups use a set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
Designer style sheets give fields and draws their size, anchor, borders,
fills, fonts and caption placement through usehref references to elements
in a <proto> subform (XFA 3.3, chapter 6, "Prototypes"). The parser did
not follow them, so such forms lost their section bars, input boxes and
check-box placement.
The new crates/xfa/src/proto.rs writes the template again with every
reference into the same template merged in, and parse() reads that:
- references: usehref "#id", "#som(expr)" (with or without the legacy
"."), and use "#id" or a SOM expression; usehref wins over use;
- rules from "Overriding Prototype Properties": own attributes, data
content and children win; id and name are not inherited; children
match by class and position, and a matched prototype child is the
prototype of the element's own; a ui widget or value kind and rich
text come from the nearest layer that has one;
- prototypes in other documents are not followed (no file or network
access); a missing target, a loop (Example 6.8) or a long chain is
left out with a warning;
- caps: 32 merged layers, 256 levels of nesting, 2 million elements of
SOM search, and growth to 4x the template (1 MB floor, 64 MB ceiling);
past a cap the template is read unresolved, with a warning.
The resolver is ported from the closed#1566 by EULArule, who invited
reuse, and changed: the name attribute is no longer inherited, use takes
SOM expressions, ids and SOM look-ups are indexed and cached under one
search budget, loops through ancestors are cut, the output cap is
relative, every fallback is a warning, and the saved form state is
still read from the original XDP.
Part of #3432.
Co-authored-by: EULA <90616501+EULArule@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Without a fixed height the button is measured from its caption, so the
test now leaves `h` out and checks the button is one line of the
field's font tall, besides the face it is drawn in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
The button branch of draw_field shows the caption in the field's font with
the caption's own properties on top. No test reached it with a fontless
caption, so dropping the field font there passed. The new test fails
with the button face taken from the context outside the field (10pt
Courier instead of the field's Arial 8pt).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
A field caption is drawn in its field's font (XFA 3.3, "Formatting Text
That Appears as Fixed or Variable Content", p. 43) and the paragraph
around the field, each with the caption's own properties on top. Its
room (the reserve above, below or beside the box, a caption beside the
box measured for the field's height, a growing text field's width, and
a button's natural width) was worked out in the field's own paragraph,
so a field paragraph's space above or line height gave the caption room
its drawn text does not take. caption_reserve, field_height and
grown_text_height now take the outer paragraph.
Part of #3432.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
XFA 3.3, "Formatting Text That Appears as Fixed or Variable Content"
(p. 43): text, caption text included, is formatted by its containing
element's font properties, inherited from an ancestor container when
it names none. A field's caption was drawn in the font around the
field, so a form whose fields set Arial and whose captions set nothing
showed its labels in the 10pt Courier default. Captions are now drawn,
and placed, in the field's font with the caption's own properties on
top, as they were already measured; a button's caption likewise. The
paragraph of a field caption is unchanged.
Part of #3432.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
Packing makes an RGB image grey for every use at once, but /DefaultGray and
/DefaultRGB were checked only where the walk reads: page content and forms.
An annotation's appearance, a pattern, a Type3 glyph or a soft mask's group
drawing the same image can have other default colour spaces, so its colours
could change there.
The walk now records, by object number, every reference in the resources it
reads (each /XObject entry, drawn or not, an /XObject dictionary under its
resources, resources under a page, page-tree node or form), reading the
resources of every page and of every node above one, each page and node a
root. An image the walk reached stays covered unless an object reachable
from the trailer refers to it, or to an object on its way from a page, other
than through those references, or it is held by one that isn't covered; an
eight-bit DeviceRGB image that isn't covered stays RGB. So resources, an
/XObject dictionary or a form a page shares with an appearance keep it RGB,
as does a reference with another generation, while LibreOffice's layout (one
resources object for a page, its /Pages node, and a form inside it that
names it again) still packs. The scan runs only when packing is on and there
is such an image.
The images drawn or listed where the defaults are in force are kept by
object number too, so one named with another generation there stays RGB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* packaging: Flatpak finds and prints to CUPS printers
The Print dialog listed no printers in the Flatpak: the runtime has libcups but not
lpstat/lp, the sandbox couldn't reach the CUPS socket, and driverless network printers
(lpstat -e) need Avahi. Bundle lpstat/lp/lpoptions from CUPS 2.4.20 (Apache-2.0,
statically linked, licence installed) and grant --socket=cups and
--system-talk-name=org.freedesktop.Avahi in both manifests.
* packaging: Flatpak reads the user's CUPS settings (~/.cups, read-only)
Review (CodeRabbit): without it the sandbox's lp/lpstat ignore the user's default
printer and saved options (lpoptions) and a print server named in their client.conf.
* packaging: Flatpak CUPS tools reach the host socket when client.conf names a custom path
Review: Flatpak mounts the host's CUPS socket at /var/run/cups/cups.sock whatever
path ~/.cups/client.conf or CUPS_SERVER names, so lp/lpstat/lpoptions now run through
a wrapper that points a socket path missing in the sandbox there. Server names
(remote servers) and sockets that exist are left alone. Tested in the sandbox:
CUPS_SERVER=/run/custom/cups.sock lists the host's printers through the wrapper and
none without it; a host name is passed through unchanged.
* packaging: redirect a custom CUPS socket only when it is the one Flatpak mounted
Review (CodeRabbit): Flatpak picks the socket it mounts at /var/run/cups/cups.sock
with stricter rules than CUPS (flatpak-run-cups.c: a socket CUPS_SERVER, else the
first line spelled exactly "ServerName /path" in ~/.cups/client.conf, else the
default), while CUPS reads the keyword in any case and takes the last ServerName. The
wrapper now redirects only when CUPS' socket is the one Flatpak chose, so a job can't
reach a different server; otherwise CUPS fails on the missing path.
* packaging: never redirect a CUPS_SERVER the sandbox was given
Review (CodeRabbit): Flatpak picks the socket it mounts from the host's CUPS_SERVER,
so one set by flatpak run --env or an override may not be what it mounted. The
wrapper now leaves any CUPS_SERVER alone and redirects only a client.conf socket that
matches Flatpak's choice; otherwise CUPS fails on the missing path instead of
reaching a different server.
* packaging: point CUPS at the mounted socket only when it is the one Flatpak chose, else fail
Review (CodeRabbit): with a custom socket listed first and the default last in
~/.cups/client.conf, Flatpak mounts the custom one at /var/run/cups/cups.sock while
CUPS picks the last line, finds that path, and talks to the custom server. The
wrapper now compares CUPS' socket with Flatpak's choice even when the path exists:
equal, CUPS is pointed at the mount; different, the tool fails with an error instead
of reaching another server.
`row.border.edge[0]` with a field `border` in the row no longer falls back
to the row's own border when the field has no `edge`; `row.#border` still
names the property by class (XFA 3.3 p. 96). `namedItem` on a list of
property objects reads each name as written in the run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
docs/target-app-parity.md's optimize row lists lossy JBIG2, refinement
coding and a symbol dictionary shared between images as missing, with a
status line and a revision row.
From reviews with the pdfcraft-review skill.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
The optimizer now writes JBIG2 images as a symbol dictionary and text
regions, and Export ▸ Images has to read them back. A page of three
repeated letters, symbol coded (smaller than the generic coding),
exports as its picture. The test is added to create.export-all-images'
parity evidence. Asked for in pre-push review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
Review of the previous commit:
- Nothing checked the segment numbers the region split assigns: a
mutant numbering every region 2 decoded. The many-marks test now
reads each segment's number, and has a bar too tall to be a symbol,
so the generic region is numbered after the last text region.
- The decoder's 32,767-symbol limit was checked against all distinct
marks, before either plan, so an image with more distinct marks lost
the second plan, which codes only the repeated ones. The limit now
applies to each plan (MAX_CODED_SYMBOLS); finding marks keeps its
memory bound of 65,536 (MAX_SYMBOLS), as before the previous commit.
A test has 32,768 distinct marks above a page of repeated text, which
encode_jbig2 still symbol codes through the second plan.
- The dense-page optimizer test now checks that it takes several text
regions, and a compile-time assert keeps segment numbers within a
byte's reach.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
A review found that a dense page came out as a stream PdfCraft's own
renderer refuses, so the page drew blank after optimizing: hayro-jbig2
decodes a text region of at most 10,000 symbol instances, and refuses
32,768 symbols or more. The stream was valid (Poppler decoded it), but
every mark went into one text region and up to 65,536 symbols were kept.
A 300 dpi letter page of the optimizer test's own text crossed it.
A page with more than 10,000 marks is now placed by several text
regions, each over a band of rows and all referring to the one symbol
dictionary, which each region but the last keeps retained (7.2.4). Past
32,767 distinct symbols the image is coded generically.
New tests: 25,000 copies placed by three regions, which decode; the
symbol caps decoded, not just reached; and in the optimizer, a whole
letter page of rendered text that looks the same as JBIG2 symbols (it
drew blank before). The READMEs say "still looked at" for the caps, and
that the scans figure is the six pages' total (20% on one page).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
A second review found two rules tested one way only: a mark 257 tall
(not just wide) is left to the generic region, which also bounds the
bitmap allocated for each mark, and runs joined at the lower-left corner
are one mark. The test now has a 1 x 257 column and an anti-diagonal.
The caps on distinct symbols (65,536) and their pixels (2^24) are tested
at and past them, as the run and row caps are.
The scans figure now names its noise: with 2% or more of the letters'
edge pixels flipped, symbols save at most 8% over the generic region.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
Review found behaviour the tests let break unnoticed (each was a
surviving mutant, and each new test fails on it):
- black padding bits: a run reaching past the row would stop symbol
coding on many scans;
- Annex A's 32-bit range and PREV at exactly 256, where a decision would
go uncoded: coordinates past 4,435 on a 12,000-pixel-wide and a
10,050-row page, and the contexts of 4436's coding;
- marks joined at a corner are one mark; 256 pixels a side is a symbol,
257 is left to the generic region;
- the run and row caps, at and past them.
The roadmap's status line for this change now comes first, and the
"about a third smaller than Group 4 on scans" figure is replaced by what
was measured: 27-33% on the same pages with scan-like noise added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
pdfcraft_filters::encode_jbig2 stores each distinct mark of a 1-bit
image (8-connected black pixels, at most 256 a side) once, as a symbol
in a symbol dictionary, and places its exact copies with an immediate
lossless text region that refers to it. Larger marks, and in a second
plan marks that occur once, go to a generic region over their box. It
keeps whichever of that and the generic coding (encode_jbig2_generic,
unchanged) is smaller. Only exact copies share a symbol, so the stream
decodes to the same bits.
Written from the JBIG committee's ISO/IEC 14492 Final Committee Draft:
6.4 and 6.5 (text region and symbol dictionary decoding), 7.2, 7.4.2
and 7.4.3 (segment headers and syntax) and Annex A (the integer coders,
checked against its worked example and Table A.1).
On six pages of rendered 300 dpi text the output is 28% of the generic
coding's size and 17% of Group 4's, at about 100 ms a page; hayro-jbig2
and Poppler (pdfimages) both decode it to the original bits. Scans,
whose copies of a letter are seldom identical, gain little: that needs
refinement coding. A dictionary shared between pages (/JBIG2Globals)
is a further step.
The optimizer's Monochrome Images > JBIG2 (lossless) and doc_optimize
mono jbig2 use it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P6yUtvWGPsJpMLyh6pxSXG
An image's /JBIG2Globals were decoded with the 1 GiB any stream may decode
to, before the JBIG2 page's size is known, so the page's pixel limit didn't
bound them: a few kilobytes of Flate could make export allocate up to 1 GiB.
They now decode within MAX_GLOBALS (32 MiB); globals past it skip the image,
with the limit in the reason. The test covers one byte over and exactly the
limit, and the image's /DecodeParms direct, by reference and in an array.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An annotation's /AP can hold entries that no reader draws. Only the
normal, rollover and down appearances (N, R, D) now keep a Type 3 glyph,
so an extra entry such as /X can no longer keep a redacted glyph program
in the saved file.
Rewriting a page also dropped a Type 3 font that only an annotation
appearance without /Resources selects, although that appearance draws
through the page's resources. The page prune now reads those appearances
too. It reads them only when the page lists a Type 3 font, so other files
are not refused over an appearance it cannot parse.
Two tests, both failing without this change.