Commit Graph
80 Commits
Author SHA1 Message Date
Dylan M. Taylor d31a96f46f Merge pull request #4121 from aiongg/fix/coderabbit-c1-js-xfa
fix(js, xfa): bound the text and work that form scripts and XFA data can multiply
2026-10-22 21:39:08 -04:00
aiongg 1e2ac1d85a fix(xfa): copy embedded field values out only as far as the text budget
The text layout cut each embedded value to the bytes its block had left, but
the resolver cloned the whole value first. With a byte or two left and a
value starting with a multibyte character, every later run cloned the full
value and kept none of it. The resolver is given the bytes left and returns
only a prefix that fits.
2026-10-22 20:21:21 +00:00
aiongg 668d8f777e fix(xfa): every drawn subform instance spends the layout budget
A positioned root draws its children instead of flowing them, so nested
repeating subforms under it multiplied their instances without spending
the measurement budget that flowed instances spend. Drawing a subform
instance spends it too.
2026-10-22 20:08:33 +00:00
aiongg ee33337627 fix(xfa): bound the name bytes of data nodes a write creates
Writing a value at a high index creates every missing sibling before it,
each with its own copy of the name. The node budget counted siblings but not
their names, so a long name with a high index made thousands of copies of
it. The write's budget also counts the bytes of the names it creates; a
path past it is skipped with the existing warning.
2026-10-22 17:22:50 +00:00
aiongg bac0e610db fix(xfa): bound the bytes a data import copies out of its file
Converting an imported data file copied each element's and attribute's
resolved namespace URI, so a long namespace declared once on the root was
copied into every element that inherits it; only the node count was
limited. The import counts the names, namespaces, attributes and text it
copies against a byte budget of four times the file-size limit, and refuses
the file as too large past it.
2026-10-22 17:22:50 +00:00
aiongg a07ad60d52 fix(xfa): queue each added data instance once per pass
write_data_ops expanded every instance-count op into one queued node per
instance, then deduplicated the pass. A script adding rows one at a time
asks for one more instance each time, so n rows queued about n*n/2 nodes
before the deduplication. Each op queues only the instances the pass has
not queued yet, and a budget bounds the instances queued across passes
that removals separate, with a warning past it.
2026-10-22 17:22:50 +00:00
aiongg 1dbfa25100 fix(xfa): bound the script text the live form's events hold
Every instance of a repeated subform records its own copy of each script,
and only the number of events was capped. A long script inside nested
repeating subforms was copied once per instance before any script ran. The
events hold at most as much script text as the XFA packets may; past that
the live form is marked truncated, as it is past the event cap.
2026-10-22 17:22:50 +00:00
aiongg 3412437191 fix(xfa): bound the embedded field text one text block expands
Rich text resolved every embedded-field reference to a fresh copy of the
field's value, so a template repeating one reference to a long value many
times laid out a copy per reference. One text block expands at most as many
bytes of embedded values as a text of its own may hold; past that the
values are cut.
2026-10-22 17:22:50 +00:00
aiongg 17f5d80f44 fix(xfa): break a long word in linear time
Text layout broke a word wider than its line by measuring the whole growing
piece after every character, and counting its characters again each time.
A long unbroken word in a wide box with a small font made that quadratic.
The piece's advance is kept as a running sum of character widths instead.
2026-10-22 17:22:50 +00:00
aiongg 306627ee77 fix(xfa): read a packet stream the XFA array lists again only once
The packet reader decoded the stream of every /XFA array entry and
charged only the decoded output to its 64 MB budget, so one stream that
decodes to almost nothing (Flate over hex whitespace), listed many
times, repeated a large decode for free. A stream reference already
read is skipped.
2026-10-22 17:08:55 +00:00
aiongg 2e1c029fa8 fix(xfa): every flowed subform instance spends the layout budget
Nested repeating subforms multiplied their instances (up to 50 per level
over 64 levels), and an empty instance neither measured nor placed
anything, so it spent none of the measurement or item budgets. Each
instance now counts as a measurement, and layout stops with TooLarge
once the budget is spent.
2026-10-22 17:08:54 +00:00
aiongg f84eeaed7a Integration: a non-interactive XFA field is measured at the width it is drawn (#3515 × #3521)
#3515 measures a growing non-interactive field at its text's scale but
with a widget's 4pt of padding, while the layout draws its text without
it. Once #3521 fits lines by their ink, the narrower measuring width
wrapped to one more line than the drawn text, leaving a blank line
below it. The measurement leaves out the padding the draw doesn't have.
2026-10-22 04:15:17 +00:00
aiongg 4b85c697f9 Merge PR #3521: M12: a space at the end of a line doesn't count when fitting XFA text
crates/xfa/src/tests.rs: union of #1648's TIFF orientation test and #3521's tests.
2026-10-22 01:49:27 +00:00
aiongg b2b42c89db Merge PR #2993: Render month and weekday names in XFA date patterns
crates/xfa/src/data.rs: #2993's month and weekday helpers and date_tokens doc, with date_tokens kept pub(crate) for #3782's formatted_value and #3397's data pictures.
2026-10-22 01:49:20 +00:00
aiongg da7f592cd0 Merge PR #1648: XFA: decode BMP and TIFF pictures
crates/xfa/src/tests.rs: union of fixture imports (tiny_bmp, tiny_tiff).
parity/acrobat-features.toml: form.xfa and the XFA image entry: evidence lists unioned, notes take both sides' insertions.
2026-10-22 01:49:05 +00:00
aiongg 88c21daaed Merge PR #2615: fix(xfa): enforce maxLength on rich-text fields
ROADMAP.md, docs/roadmap.md: all status lines and progress-log lines kept; M12 row takes both 'Done since' insertions.
parity/acrobat-features.toml: form.xfa evidence lists unioned, notes take both sides' insertions.
2026-10-22 01:48:32 +00:00
aiongg 9865f27d8c Merge PR #2619: fix(xfa): run click scripts for every repeated print button
ROADMAP.md, docs/roadmap.md: both status lines and progress-log lines kept; M12 row takes both 'Done since' insertions.
crates/automation/tests/automation.rs, crates/xfa/src/fixtures.rs: union of #2624's and #2619's tests and fixtures.
parity/acrobat-features.toml: form.xfa evidence lists unioned, notes take both sides' insertions.
2026-10-22 01:48:18 +00:00
aiongg a0a9e3370e Merge PR #3408: M12: an XFA script that fails partway keeps what it changed before the error
crates/engine/src/tests.rs: union of #2624's tests and #3408's test.
parity/acrobat-features.toml: form.xfa evidence lists unioned, notes take both sides' insertions.
2026-10-22 01:47:22 +00:00
aiongg 3ba586fe31 Merge PR #2624: fix(xfa): reflow growable multiline fields after filling
crates/xfa/src/script.rs: template_field and named_in moved to crate::data in #3397; field_grows_with_text calls crate::data::template_field.
parity/acrobat-features.toml: form.xfa evidence lists unioned, notes take both sides' insertions.
2026-10-22 01:46:50 +00:00
aiongg be69bfadf9 Merge PR #3515: M12: XFA text honors its horizontal font scale
crates/xfa/src/layout.rs: both sides added doc comments to value_height, caption_reserve, field_height, unique_name and draw_field; kept HEAD's, with #3542's natural_width.
2026-10-22 01:46:14 +00:00
aiongg 8031d345d4 Merge PR #3542: M12: XFA labels and buttons without a size grow to their content
crates/xfa/src/layout.rs: both sides added a draw_field doc comment; kept #3542's (the more complete one).
2026-10-22 01:46:05 +00:00
aiongg dbc2647f48 Merge PR #3397: M12: XFA dates are written and read in the field's data picture
crates/engine/src/tests.rs: union of #3180's new test and #3397's doc comment on the next test.
crates/xfa/src/layout.rs: kept #3782's formatted_value (it calls date_pattern, now built on date_letters) and button_action doc.
crates/xfa/src/parse.rs: parse_field doc comment from #3397 (names the data picture).
crates/xfa/src/script.rs: field() doc from #3582 with #3397's "as scripts read it".
crates/xfa/src/tests.rs: union of fixture imports and of the new tests; one doc comment each for the date-conversion and data-fill tests.
2026-10-22 01:45:58 +00:00
aiongg 0bf197f07b Merge PR #3582: M12: showing an XFA subform leaves its unnamed hidden objects hidden
crates/xfa/src/script.rs: both sides added doc comments to the same functions; kept #3582's (they describe its presence(name, ...) signature).
2026-10-22 01:45:16 +00:00
aiongg 9cb8f52294 Merge PR #3782: M6: XFA formattedValue shows a date in the field's display picture 2026-10-22 01:44:53 +00:00
aiongg 5d7b9a98b3 Merge PR #3192: fix(forms): an XFA form whose config forbids dynamic rendering is static (#3180) 2026-10-22 01:44:51 +00:00
Eric Kaden 526d87d85c M6: formattedValue formats only a value of the ISO date's own shape
2026-1-2 isn't an ISO date and stands as it is. A test also pins that
parentheses hold a picture's locale (date(en_US){YYYYMMDD} formats) and
that a clause without braces has no pattern.
2026-10-21 00:09:00 -04:00
Eric Kaden 21b6267129 M6: a display picture with month or weekday names leaves formattedValue raw
date{DD MMM YYYY} and date{EEE …} have parts formatted_value can't show
yet, so it gives the raw value instead of text like 20 mmm 2026.
2026-10-20 23:57:14 -04:00
Eric Kaden 6a8ea287aa M6: doc comments on the functions the formattedValue change touches 2026-10-20 23:37:21 -04:00
Eric Kaden c0a513eed8 M12: scripts read a date in its data picture as the ISO date
A date the field's data picture writes as 20261018 reaches scripts as
2026-10-18, the rawValue another viewer gives them, so a script that
checks String(rawValue).length == 10 works (DA Form 31's 10b TO).
Doc comments on the functions this branch touches.
2026-10-20 23:33:23 -04:00
Eric Kaden 7176ebde94 M6: XFA formattedValue shows a date in the field's display picture
Fields keep their <format><picture>. A date display picture turns the
ISO value into its pattern for scripts' formattedValue (JavaScript and
FormCalc), so date arithmetic on formattedValue works as forms expect.
Once a script sets the value, formattedValue gives that value. Number
and text display pictures still give the raw value.
2026-10-20 23:29:08 -04:00
Eric Kaden 572e01a71d M12: the wrapping test checks the text stays within its room 2026-10-20 09:39:32 -04:00
Eric Kaden f9daeeb1fa M12: doc comments for the functions around this change 2026-10-20 09:25:19 -04:00
Eric Kaden 15eef03efc M12: doc comments for the functions around this change 2026-10-20 09:24:47 -04:00
Eric Kaden ee91673162 M12: doc comments for the functions around this change 2026-10-20 09:21:31 -04:00
Eric Kaden ec14687c6d M12: a draw without text or a width keeps the width it has room for 2026-10-20 09:20:55 -04:00
Eric Kaden a3b942021f M12: doc comments, and words keeps its own 2026-10-19 23:46:56 -04:00
Eric Kaden 5cd7e816b9 M12: doc comments for the functions this change touches 2026-10-19 23:46:16 -04:00
Eric Kaden 24b55275a5 M12: doc comments for the functions this change touches 2026-10-19 23:46:14 -04:00
Eric Kaden 15ab8c7a2c M12: doc comments for the functions this change touches 2026-10-19 23:42:22 -04:00
Eric Kaden 35e04743d0 M12: showing an XFA subform leaves its unnamed hidden objects hidden 2026-10-19 21:27:47 -04:00
Eric Kaden 37f43e947d M12: an XFA button's box is its whole field
A button was given its content area (inside its margins) as its widget
rectangle, though its border belongs to the field: DA Form 31's
Instructions button, with a 1.25 pt top margin, came out shorter than
the Attachments Menu button beside it. Its box is now the whole field;
the margins pad the caption.
2026-10-19 15:41:00 -04:00
Eric Kaden da38e0da6f M12: an XFA button without a height is as tall as its caption
A button with no height was sized like a text field in its field font,
with text-field padding, so DA Form 31's Instructions button (10 pt
field font, 8 pt caption) came out about 17 pt tall and over the form
below it. It is now as tall as its caption, never below its minimum.
2026-10-19 15:26:37 -04:00
Eric Kaden 32bb14b952 M12: an XFA label or button without a width is as wide as its text
A draw or a button with no width took all the width available, so a
right-aligned label slid to the far side of its subform and a button
spread over what lay beside it: DA Form 31's Instructions button covered
its header and the email line, and its PERSONNEL/FINANCE line ran into
the field after it. They now grow to their text, unwrapped, within what
is available and never below their minimum width, as containers do.
2026-10-19 15:06:32 -04:00
Eric Kaden 6dc8ad933b M12: spaces alone stay on an XFA text line
A word of spaces alone draws nothing, but after a word whose own
trailing space ran past the box it failed the fit test and opened a
blank line, so the text measured a line taller than it draws. Such
words now always stay on the line, keeping their width.
2026-10-19 14:53:28 -04:00
Eric Kaden dd782bca1d M12: a non-interactive XFA field is measured at its text's horizontal scale
The layout draws a non-interactive field's text itself, condensed, but
measured its height at full width, so a condensed value reserved lines
it didn't use. Fields now measure and draw their text in one face:
scaled when the layout draws it, as designed when the forms layer does
(the over-page fallback included).
2026-10-19 14:42:37 -04:00
Eric Kaden b2f40e0442 M12: a space at the end of a line doesn't count when fitting XFA text
Words keep the space after them, and the line-fit test counted it, so a
label written with a trailing space wrapped when its box was a fraction
of a point narrower than the label plus that space: DA Form 31's 'a.
DATE ' and 'b. TIME ' put their second word on top of the field below.
A line now fits by what it draws, and alignment ignores every trailing
space, not just one.
2026-10-19 14:22:22 -04:00
Eric Kaden 162a891673 M12: XFA text honors its horizontal font scale
fontHorizontalScale on a font, and xfa-font-horizontal-scale in rich text,
condense the glyphs; PdfCraft ignored both, so condensed labels were laid
out at full width and overflowed or wrapped where the form fits them on
one line. Text is now measured at its scale and written with Tz, in a
graphics state of its own. Field values keep full width: the forms layer
draws them, and its appearances have no horizontal scaling.
2026-10-19 13:56:03 -04:00
Eric Kaden 8f0557d2bc M12: an XFA script that fails partway keeps what it changed before the error 2026-10-19 01:13:09 -04:00
Eric Kaden 097c452c84 M12: a date its data picture can't hold stays ISO in the data
A two-digit year reads back as 1950 to 2049, so 2050 written as 50 came
back as 1950. A date is now written in the data picture only when it
reads back from it unchanged.
2026-10-19 00:26:05 -04:00
Eric Kaden 38d3a6c843 M12: each XFA date field uses its own data picture, and only a whole-date one
The template field behind a SOM path is now found by its number, as the
form numbers same-named siblings and repeated instances; the live form's
value refresh uses the same lookup. A data picture without a year, month
and day (date{YYYYMM}) keeps ISO dates in the data, since it can't hold
the date the field shows.
2026-10-19 00:18:03 -04:00