Skip to content

Ignore signed \'hh hex escapes in RTF outline import - #1351

Merged
h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h2405-rtf-outline-import-accepts-a-sig
Oct 25, 2026
Merged

h-a-n-a-s-h-i merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h2405-rtf-outline-import-accepts-a-sig

Conversation

@Silvertree2010

@Silvertree2010 Silvertree2010 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Found while testing crates/format/src/rtf.rs:226 (rtf_to_outline) (no existing issue): RTF outline import accepts a '+' sign in 'hh hex escapes and inserts a control character.

Cause

The RTF reader decoded the two characters after \' with u8::from_str_radix(h, 16), which accepts a leading +. So \'+5 became byte 0x05 and a control character was added to the slide text.

Fix

Before parsing, the reader now checks that both characters after \' are ASCII hex digits. Any other pair is ignored like other malformed escapes.

Verified

  • Regression test rtf::tests::hex_escape_rejects_sign: fails on main without the fix and passes with it (cargo test -p deckcraft-format --lib hex_escape_rejects_sign).
  • cargo xtask ci passes.

🤖 Generated with AI by ApolloOffice, see the Co-Authored-By trailers for the models

Summary by CodeRabbit

  • Bug Fixes
    • RTF text with malformed hexadecimal escapes is now handled consistently: escapes are accepted only when both characters are valid hexadecimal digits. Invalid forms, such as \'+5, are ignored rather than interpreted as signed numbers. Valid hexadecimal escapes continue to be supported, helping prevent malformed input from producing unintended character values.

Found while testing crates/format/src/rtf.rs:226 (rtf_to_outline)

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a0eeb34 and 9c985e6.

Files selected for processing: 1
  • crates/format/src/rtf.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The RTF parser now accepts hex escapes only when both characters are ASCII hexadecimal digits. A regression test checks that a signed escape is ignored.

Changes: RTF escape validation

Layer / File(s) Summary
Validate RTF hex escapes
crates/format/src/rtf.rs
The parser requires two ASCII hexadecimal digits for an escape. A regression test checks that a signed escape is ignored, yielding ab\n.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: nikitkara

Merge Risk: Minimal · up to 9c985

The change is narrowly scoped and does not establish a merge-blocking risk.

Architecture risk: Medium · up to 9c985

The change affects 1 system.

Changed systems: crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/format/src/rtf.rs: Hex escapes now require two ASCII hexadecimal digits before parsing; malformed escapes containing signs or other non-hex characters are ignored.
  • observed — Modified behavior in crates/format/src/rtf.rs: Added a test asserting that a signed value in a \'hh escape is ignored, yielding ab\n.

Reliability and maintainability

  • inferred — Risk-relevant change factors for crates: blast_radius_1; direct_dependents_1
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: ignoring signed \'hh hex escapes during RTF outline import.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit ec274ec into storytold:main Oct 25, 2026
3 checks passed
@echelon

echelon commented Oct 25, 2026

Copy link
Copy Markdown
Member

Landed on main — thank you for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants