Commit Graph
6 Commits
Author SHA1 Message Date
aiongg dbcf3998ac craft-pdf: the cos suite uses the crate's testkit instead of loading the file a second time 2026-11-23 00:27:47 +00:00
aiongg 134abcc8dc Build the tests next lost in the sync into the crates' test executables
pdf (cos, crypt, filters, font_tables), cms (gpu_matrix_shaper) and prepress (marks, flatten_timings) had no mod line in tests/main.rs, so they never compiled. Module paths inside the one executable are adjusted (crate:: to super::, the child-process test name).
2026-11-23 00:11:29 +00:00
Michael Higgins d851c9b2e3 craft-pdf: a rebuilt xref keeps the generation-0 object the page draws (cos) (#2240)
When the cross-reference data is rebuilt from object headers, the index
was keyed by object number alone, so a later `N 1 obj` replaced
`N 0 obj` while the renderer still drew `N 0 obj` under `N 0 R`. cos
read the page's object as null and a full save wrote null
(storytold/pdfcraft#6759).

Each number now keeps its object by the renderer's rule: the last real
`N 0 obj`, else the last header as a generation-0 stand-in. Where a
number has headers of several generations, a bounded walk from the
trailer gives the slot to the one generation the document reaches,
when it reaches one only, so a reused number such as PDFBOX-3785's
`202097.pdf` keeps its page. A trailer /Root is ranked by its own
generation's header, and a slot whose object stream supplies indexed
members stays. What one slot cannot hold goes to the repair log, and
Document::rebuilt_with_unsettled_generations() says when a save could
differ from what the renderer drew.

Port of storytold/pdfcraft#6767, which can't land in pdfcraft since cos
moved here.
2026-11-18 15:30:17 -05:00
mtlcl410 19f851b8db craft-pdf: crypt and cos read every password spelling and key length other readers accept, and report crypt filter methods they can't decrypt (#1343) 2026-11-16 21:36:23 -05:00
Dylan M. Taylor d74e60b2d5 craft-pdf: refuse to create RC4 encryption without an explicit legacy call
The create() API exposed RC4-40 and RC4-128 behind a doc comment, so an app
could write files whose encryption protects nothing. create() now returns
Unsupported for both schemes; create_legacy() and
Document::set_encryption_legacy() are the explicit ways to write a file that
must stay readable by an old reader. Tests and the encrypt example, which
read and write every algorithm, use the legacy entry points.
2026-11-14 12:57:23 -05:00
Dylan M. Taylor fa389c7883 craft-pdf: the PDF object layer from PdfCraft (cos), on filters and crypt
craft-pdf: the PDF object layer from PdfCraft (`cos`), on filters and crypt

* hayro-jbig2: bound a stream's total decode work and what a page retains; no i32 overflow

Port of pdfcraft 85c10051 (patches 5-9), 82439525 (patch 10) and 10107d94 (patch 12).

* hayro-jbig2: PdfCraft's JBIG2 follow-ups (refinement fixes, file header, work accounting, dictionary pixel cap)

Ports pdfcraft 72e763ad, b7ec3669, e3bc4e85, 01d3479f, b9e068aa, 858ce960, 07f44038, e38b9d18, 8717a085, 58c30af3 and the hayro-jbig2 part of e2464e14 (with the hayro-jbig2 part of 0ed33990 they build on).

* Add craft-stream-codecs: the codec modules of PdfCraft's stream filters

LZW, ASCII85, ASCIIHex, RunLength, the TIFF and PNG predictors, bounded CCITT
fax decoding (through hayro-ccitt) with Group 4 encoding (through fax), and
the lossless JBIG2 encoder with its MQ coder, from pdfcraft-filters at
PdfCraft revision 80e26e674d1aa33078e83c8139875047f3289eb6.

The crate sits below craft-pdf and craft-tiff: it knows no container. The
PDF filter chain, Flate and the bounded JBIG2 decoding entry are not part of
it.

* craft-pdf: the PDF filter chain from PdfCraft (`filters`)

Adds the `filters` feature: the /Filter chain of pdfcraft-filters (PdfCraft
revision 80e26e674d1aa33078e83c8139875047f3289eb6) as craft_pdf::filters,
over the codecs in craft-stream-codecs. It adds Flate, strict and tolerant
chain decoding, byte accounting and a shared work allowance, and encoding,
with the chain's unit tests, its property tests and its fuzz target.

The code is unchanged apart from the imports of the moved codecs; FilterError
is craft-stream-codecs' CodecError under its old name.

* craft-stream-codecs: bounded JBIG2 decoding (decode_jbig2_within)

The JBIG2 decoding entry of pdfcraft-filters (PdfCraft revision
80e26e674d1aa33078e83c8139875047f3289eb6, src/jbig2/decode.rs) with its tests.
It spends from the caller's work allowance through hayro-jbig2's
Image::decode_within and charge_reading, which come with
fix/sec-hayro-jbig2-followups (#886).

* vendor/README.craft-reader.md: one #831 paragraph, the follow-ups after it

* craft-pdf: filters re-exports decode_jbig2_within (and lib.rs module order)

* craft-pdf: the object layer from PdfCraft (`cos`)

Adds the `cos` feature: PdfCraft's pdfcraft-cos crate (revision
1d2af9907ba772b368f6b54811359805fa5428e9) as craft_pdf::cos, on crypt and
filters, with its unit tests, integration tests and examples. Its test helpers
come with it: pdfcraft-testkit as src/cos/testkit.rs (cfg(test)) and the qpdf
runner of pdfcraft-oracle as tests/cos/oracle.rs.

The code is unchanged apart from module paths and doc comments. The child test
of file_identifier is named by its module path, since the integration tests
are one binary.

* craft-pdf: cos unit tests build for wasm

The property tests in src/cos/writer.rs need proptest, a dev-dependency of
the non-wasm targets only, and one test in src/cos/document/tests.rs times a
load on a thread, which wasm32-unknown-unknown does not have. Both are
compiled for non-wasm targets only; the other unit tests still build for wasm.
2026-11-11 22:44:59 -05:00