Objects are followed from the trailer through a queue of references,
never into /PieceInfo, so an object only private data refers to is not
read as a graphics state holder. /HalftoneType must be an integer
(ISO 32000-1 Table 128); a real of the same value is reported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Graphics states come from /Resources and /DR entries and from shading
patterns, never from private /PieceInfo data, and maps shared by
reference are read once. A halftone without a /HalftoneType, a
rendering intent that isn't a name, and a halftone /TransferFunction
where it isn't allowed or is missing (non-primary colorants of a type 5
halftone need one; ISO 32000-1 Table 130) are reported. A null entry
counts as absent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Keeps main's reworded mono-image text and the target_bytes paragraph in the doc_optimize description.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An engine test converts files without a binary comment and with a 2.0
header, saves them through Session::save_bytes and verifies the
reopened bytes; the preflight test adds a good version with a short
comment, and a good header that conversion leaves alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
A graphics state may not have /TR, may have /TR2 only as /Default, may
use halftones of type 1 or 5 only and without /HalftoneName (also the
colorant halftones of a type 5 one), and a rendering intent from ISO
32000-1 Table 70. Graphics states are read from every /ExtGState
resource dictionary and from shading patterns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
The file must start with %PDF-1.0 to %PDF-1.7 and an end-of-line marker,
followed by a comment of % and four bytes above 127. A document whose
next save is a full rewrite is judged by the header that save writes.
Save as PDF/A makes the next save full, at version 1.7 when the kept
version isn't 1.0 to 1.7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
A /Colorants entry counts only as a Separation space of its own colorant
(ISO 32000-1 8.6.6.5, Table 71). Tint-transform and other streams compare
by decoded data, so the same function stored under another filter is the
same. Equal reference pairs are remembered and comparisons are bounded,
so a structure shared by many definitions is compared once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
A draw's fit passes ran on after one had spent the budget, each a full
measure, before the draw was refused; each pass now checks the budget before
it starts and after it ends. The final layout pass, which expands the
embedded values once more, is checked too, so the draw that crosses the
budget there is refused even when it is the form's last. (CodeRabbit review
on #5852.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Finishes the clause. Table C.1 of ISO 32000-1 Annex C bounds real values
at about ±3.403 × 10^38 and character identifiers at 65535. A real past
that range (an integer token too long even for a real reads as one) is
reported, and so is an embedded CMap of a Type 0 font, or one it uses
through /UseCMap, whose begincidrange entry reaches past CID 65535 or
whose begincidchar entry names one (ISO 32000-1 9.7.5.4). A CMap named
rather than embedded is a predefined one, within the limit. The CMaps are
decoded within one 16 MiB allowance.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Upstream now counts the parsed tree and keys in held_bytes and tracks the cache total itself,
which replaces this branch's copy of the cache accounting and its owned_bytes. write_full's
retention budget uses held_bytes; the separate node budget is dropped since held_bytes counts nodes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From the review of #6203:
- Separation definitions are compared as objects, references followed at
any depth (to 32), so identical streams under different numbers agree;
- All and None are compared like any other colorant name;
- colorant names and /Process components given by reference are resolved;
- /Process exempts its components only in an NChannel space;
- a null /Colorants entry, or one referring to no object, defines nothing;
- colour spaces are found as deep as the parser nests them (128).
Corpus results are unchanged (15 of 23 6.2.4.4 files right, no new false
failure).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Each pass over a draw's text counted only its own characters, so a short
text embedding a long field value, drawn in many instances, never spent the
budget. The embedded values each pass lays out are counted too.
(CodeRabbit review on #5852.)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
From the review of #6202:
- the trailer is scanned with the indirect objects;
- a page's /Contents streams are read joined, as one content stream:
operands may end one stream and their operator start the next
(ISO 32000-1 7.8.2);
- values are followed as deep as the parser nests them (128);
- content is decoded within one 256 MiB allowance for the document;
- a page box whose size overflows to infinity is reported;
- the test covers a long name used as a content operand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Separation spaces of one colorant name must agree on their alternate
space and tint transform, inside a DeviceN space's /Colorants too, and a
DeviceN space must name each spot colorant it uses in its /Colorants
(ISO 32000-1 8.6.6.5, Table 71). Process colorants (Cyan, Magenta,
Yellow, Black and an NChannel space's /Process components) and None need
no entry. Verify PDF/A now reports both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
PDF/A-2 6.1.13 keeps a file within the limits of ISO 32000-1 Annex C
(Table C.1 and the page sizes after it). Verify PDF/A now reports an
integer outside 32 bits, a string over 32767 bytes, a name over 127 bytes
(counted decoded, so #xx escapes don't inflate it) in an object or in
content, and a page boundary under 3 or over 14400 units, read after
inheritance so a page's own box overrides its parent's. Character
identifiers over 65535 are not checked yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
Full screen veils a page until its raster is in, and a click on a veiled
page turns it. The test clicked after six frames; on a slow CI runner the
raster wasn't in yet, so the click on the field turned the page. It now
waits (up to 600 frames) until DocView::presentation_settled says the page
is wholly in view.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyDBXygTf7jcqdsjcfn
A /CIDToGIDMap, CMap or program whose /DecodeParms are an indirect
object, or an array holding one, was decoded without them, as on main:
behind a PNG predictor its tag bytes stayed in, so the map read wrong
and the CMap or program not at all. Each of the five metrics reads and
the editor's program read now go through Document::with_direct_parms,
which shares the stream's data and copies its dictionary only when a
parameter is indirect.
Reads::decode's comment now says what the stage bound does: a stage may
make more than the stream's limit where a decode without an allowance
stops it, and a stream past its limit counts as refused when what is
left can't pay for its stages.
Found by the Legal forms review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
A DecodeBudget bounds what a stream's filter stages make together, and
the first commit passed it each stream's own limit, so a /CIDToGIDMap of
65,536 CIDs behind ASCIIHex and Flate (131,072 bytes, with the hex
stage's output on top) went unread, where a decode without an allowance
bounds each stage alone and read it. Every Metrics::from_dict caller saw
the font as missing those glyphs. The 16 MiB limits on CMaps and
programs had the same edge.
Each stage may now make up to the stream's own limit, as before, and
the allowance pays for all of them; what the stream decodes to stays
within its limit.
Found by the Consumers review.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY
pa-Arab-PK is Punjabi in Arabic script, which Word keeps as right-to-left
text, but word_lang looked only at the language and wrote w:val. A script
subtag (Arab, Hebr, Syrc, Thaa; Hans, Hant, Hani, Jpan, Kore, Hang, Hira,
Kana; Latn, Cyrl, Grek) now decides over the language. It is read only in
its own place, after the language and any extended languages, so private
use such as en-x-arab names no script.
A singleton (one letter or digit) starts an extension, or with x private
use, and BCP 47 needs a subtag after it. en-x and en-a were written as the
document's language. They and a singleton straight after another are now
left out; one-character subtags inside private use stay allowed.
BCP 47 sets no maximum length; 35 characters is only the least a protocol
must hold. A well formed tag such as en-US-u-ca-gregory-nu-latn-co-phonebk
was left out of both exports. The bound is now 255, kept only so a PDF's
/Lang can't put an unbounded string in the file.
Word export named no language, so Word checked the spelling of every
export as English and underlined a whole document in any other
language. The PDF already says its language in the catalog's /Lang.
When that is a well formed language tag, Word gets it as the default
language of the text (w:docDefaults), in the attribute Word keeps for
its script: w:eastAsia for Chinese, Japanese and Korean, w:bidi for
Arabic, Hebrew, Persian and Urdu, w:val for the rest. Both HTML
exports, with and without CSS, get <html lang>. Without /Lang, or with a
malformed one, the files are exactly as before.
docx_with_language, html_with_language and html_simple_with_language
take the language; docx, html and html_simple stay as they are and call
them with none. The engine reads /Lang through the existing initial
view.
The new export and engine tests fail without the change.
Review fixes for Copy with formatting.
- ui-egui: the HTML copy goes through one arboard Clipboard, created on
first use and kept in the app (os_clipboard::with_kept, under the same
process-wide lock), instead of a fresh one per copy. On X11 the copied
data is served only while its Clipboard lives, so a fresh one dropped
at once could leave nothing to paste without a clipboard manager. A
failed create or set falls back to egui's plain-text copy.
- ui-egui: html_clipboard_override stands in for the system clipboard in
tests. With the system clipboard on, Copy sets HTML and plain text in
one set and emits no CopyText; when the set is refused it emits
CopyText with the plain text. The HTML is built only when a clipboard
will take it (system clipboard on, not the web build). The
last_copied_html field is gone.
- export: clipboard HTML text is escaped in one pass and also drops C1
controls, a bare carriage return and the bidirectional overrides and
isolates. Font sizes are written within 1 to 1000 pt.
- engine: the glyph-to-block step budget is a parameter, tested; the copy
says styles_incomplete only when matching actually ran out of steps.
- automation: text_extract format "html" has one 32 MiB HTML budget
across all pages; a page past it gets none, and the result carries
html_truncated. The tool description says so.
- parity: the new tests are evidence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
Metrics::from_dict decodes up to four streams of a font (its Encoding and
ToUnicode CMaps, its program, its /CIDToGIDMap), each within a limit of
its own but afresh on every call, so a caller reading many fonts that
name one large stream decodes it once per font with no total.
Metrics::from_dict_within charges each of those decodes to the caller's
DecodeBudget, and past_allowance says when one was left unread because
the allowance was spent, so a caller can refuse rather than work from
guessed widths, code lengths or meanings. A stream past its own limit is
left unread as before and doesn't count as past the allowance.
from_dict reads with no total, as before.
embedded_sfnt_within, which the editor's font listing shares one
allowance across, read the metrics that adapt a program's cmap outside
that allowance: their ToUnicode and the program again. It now charges
them, skips a composite font before reading its metrics (it never used
them), and adapts no copy from metrics read past the allowance.
Part of #5755.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY