* Issue #2385: audit finds thick strokes, black highlights and white boxes over text Three ways of hiding text that a reader sees as redacted were reported clean while the text stayed extractable: - a thick stroke along the text (`0 G 20 w 70 705 m 400 705 l S`, marker style): the walker now tracks the stroking color, the line width and `/CA`, and a single axis-aligned `m`/`l` segment stroked opaquely counts as the rectangle it paints (half the width each side); - an opaque `/Highlight` annotation dark enough to hide the text (`/C [0 0 0]`): the annotation pass now reads highlights too (color from `/C`, `/CA`, Hidden/NoView skipped) and reports them as `covered-text`; - an opaque white rectangle after dark text (`1 g 70 695 330 20 re f`): its own kind, `hidden-under-white` (relative luminance of the paint >= 0.9; the `0.9 g` table shading stays unflagged), so callers can decide. The `doc_audit_redactions` tool description lists the new covers and kind; the module docs state the limits (slanted or bent strokes, other filled paths, shadings and patterns are still out of scope). Tests: thick_stroke_over_text_is_a_cover, black_highlight_annotation_over_ text_is_a_cover, white_rectangle_over_text_is_reported_as_hidden_under_white (the report's three cases, with the hairline, yellow, translucent, hidden and outlined negatives); graphics_state_carries_across_streams now expects the white kind for its white rectangle. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: ExtGState /LW and omitted alphas, stroke width across the CTM, white first, highlight quads (#2385 review) - gs sets /LW as the line width, and a /ca or /CA the dictionary leaves out keeps its earlier value (ISO 32000-2 8.4.5) instead of resetting to opaque. - A stroke's width is measured across the segment after the CTM, so a non-uniform scale no longer widens horizontal and vertical strokes alike. - A white cover is hidden-under-white even over white text, which the contrast check had classified as covered-text. - An opaque Highlight hides what its /QuadPoints paint, not its /Rect; the /Rect stays the fallback when there are no usable quads. Tests: ext_gstate_sets_line_width_and_keeps_omitted_alphas, stroke_width_follows_a_non_uniform_ctm_across_the_segment, white_cover_over_white_text_is_hidden_under_white, highlight_covers_its_quad_points_not_its_rect * audit: document that a Highlight is judged by its dictionary, not its /AP Developed with AI assistance (Claude Code). * audit: a white Square is hidden-under-white; a hidden Redact mark is still unapplied (#2385 review) An opaque /Square with a white interior went through the dark-cover contrast test and was passed over, although it hides the text as a white rectangle in the content does: it is reported as HiddenUnderWhite, like that rectangle. The Hidden/NoView skip applied to every annotation, so an unapplied /Redact mark with either flag was no longer reported, which main reports: the flags hide the mark, not the text, so the skip is for the cover annotations only. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: a stroke's round or square caps are part of the cover (#2385 review) `stroked_rect` left the caps out, so a `1 J` / `2 J` marker line (or `/LC` in an ExtGState) painted half a line width past each end that the audit did not count: text under a cap stayed extractable and unreported. The cap is tracked like the width (`J`, `/LC`, cumulative, saved by `q`), and an axis-aligned stroke is lengthened by the pen's extent along it, `w/2 · |Mᵀ d̂|` after the CTM (the across-width is `w/2 · |Mᵀ n̂|`, the same rule). A round cap counts by its box. Butt caps, the default, add nothing. Test `stroke_caps_lengthen_the_cover`: butt, round, square, back to butt, vertical, a 4× scale along the stroke, a shear (√2), `/LC` with `/LW`, `Q` restoring it, and a stroke that reaches `IBAN` only by its cap. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: charge a highlight's quads against the comparison bound A highlight is compared with every line of its page once per quad, but was charged for one cover: a /Highlight with many /QuadPoints did page_cost x quads work for the price of page_cost. hidden_text now spends page_cost per area. QuadPoints is read only for highlights, and its length is checked before the numbers are collected. Developed with AI assistance (Claude Code). --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
pdfcraft-audit
Layer L4 (may use edit): verification tooling, the faux-redaction audit.
let findings: Vec<AuditFinding> = audit_redactions(&doc)?; // page, kind, rect, covered_text
It reports two kinds of finding:
- faux redaction: an opaque filled rectangle painted after text it overlaps, dark enough against the text's colour (WCAG contrast below 3) to hide it, while the text is still extractable underneath; opaque filled Square annotations count as covers too;
- unapplied mark: a Redact annotation that was marked but never applied.
A properly applied redaction removes the text, so it never flags. Page backgrounds, table shading and highlights don't either: they're painted before the text, or light against it.
A rectangle covers a text line when it hides at least half of one of the line's words, at
least 40% of the area of the words the line draws, or at least 40% of the line's box together
with a positive-area intersection with one of its words. The gap an applied redaction leaves (a TJ adjustment where the text was) is in the line's box but
holds no word, so a redaction box over it alone does not count.
Limits, by design and documented rather than hidden:
- only filled rectangles count as covers, drawn with
reor as a singlem/lsubpath whose corners form an axis-aligned rectangle (not other paths, shadings or patterns), and a translucent one (/cabelow 1) is not flagged; - covers inside form XObjects are found, but only text drawn directly in the page content is checked under them;
- annotation rectangles are compared in unrotated user space, so
/Rotatepages may misalign; - a cover that hides less than half of every word it touches, less than 40% of a line's box and less than 40% of its words (a sliver of a long value) is not flagged.
It fails closed: an undecodable content stream, malformed /Annots, form XObjects nested deeper
than 32 or in a cycle, a walk past the operator bound, more than 50 million cover-against-word
comparisons on a page, or more than 64 MiB of covered text in the report is an error, never "no
findings".
A document whose permissions withhold copying (Table 22, bit 5) still gets every finding, with
an empty covered_text: the audit hands out no text that copying would refuse.
Surfaces: the doc_audit_redactions automation tool and pdfcraft-cli audit. Both report each
rectangle in points from the top-left of the page as displayed (y down, after /Rotate), like
the other tools; AuditFinding::rect itself stays in PDF user space.