You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: cap header and footer sections at 64 KiB when fields expand - #3284
expand_header_footer (crates/engine/src/cmd/print/header_footer.rs) reads at most 10,000 characters of the header/footer code, but every &A (sheet name), &F (file name), &Z (path), &D, &T, &P, &N appended its whole value again. Sheet names from JSON workbooks are not length-checked, so 5,000 &A codes and a long name could allocate gigabytes before anything was drawn.
What changed
Field values are appended through push_field, which leaves a value out if it would take the section past MAX_SECTION_BYTES (64 KiB). Literal characters were already bounded by the 10,000-character read.
Blast radius
Print, PDF export and Page Layout headers/footers. Real headers are far below 64 KiB and are unchanged.
Checks run
cargo test -p gridcraft-engine (full suite; header/footer test extended with a 1 MiB sheet name × 5,000 &A, and 1,000 bytes × 5,000 &A stopping at 65,000 bytes (65 whole names))
Header and footer fields now have a 64 KiB limit per section. A field value is included only when it fits in full; values that exceed the available space are omitted rather than partially displayed. This applies to page numbers, page counts, dates, times, sheet names, file names, and paths.
Added checks for oversized and near-limit field values to confirm the expected display behavior.
The 10,000-character header spec was bounded, but each &A, &F or &Z
added the whole sheet name or path again, and a JSON workbook's sheet
name has no length limit. A field that would take a section past
64 KiB is now left out.
Reviewing files that changed from the base of the PR and between 8024a21 and d58afe6.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Header and footer field expansion now limits appended values to 64 KiB per section. It omits a field value when the complete value does not fit. Tests cover oversized and fitting repeated sheet-name values.
Changes: Header and footer expansion
Layer / File(s)
Summary
Bound field expansion and test its limits crates/engine/src/cmd/print/header_footer.rs, crates/engine/src/cmd/print/tests.rs
A bounded append helper limits section output to 64 KiB. Page numbers, page counts, date, time, sheet, file, and path use the helper. Tests cover repeated sheet-name values that exceed and fit within the limit.
The reviewed change has no established merge-blocking risk in the supplied scope.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: limiting expanded header and footer sections to 64 KiB.
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between df137b8 and 8024a21.
Files selected for processing: 2
crates/engine/src/cmd/print/header_footer.rs
crates/engine/src/cmd/print/tests.rs
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
expand_header_footer(crates/engine/src/cmd/print/header_footer.rs) reads at most 10,000 characters of the header/footer code, but every&A(sheet name),&F(file name),&Z(path),&D,&T,&P,&Nappended its whole value again. Sheet names from JSON workbooks are not length-checked, so 5,000&Acodes and a long name could allocate gigabytes before anything was drawn.What changed
Field values are appended through
push_field, which leaves a value out if it would take the section pastMAX_SECTION_BYTES(64 KiB). Literal characters were already bounded by the 10,000-character read.Blast radius
Print, PDF export and Page Layout headers/footers. Real headers are far below 64 KiB and are unchanged.
Checks run
cargo test -p gridcraft-engine(full suite; header/footer test extended with a 1 MiB sheet name × 5,000&A, and 1,000 bytes × 5,000&Astopping at 65,000 bytes (65 whole names))cargo clippy -p gridcraft-engine --all-targets -- -D warningscargo fmt --checkChecks not run
Summary by CodeRabbit