Skip to content

fix(docx): disable numeric coercion of Word text runs - #328

Open
eliziff wants to merge 1 commit into
Open-Legal-Products:mainfrom
eliziff:fix/docx-preserve-text-values
Open

fix(docx): disable numeric coercion of Word text runs#328
eliziff wants to merge 1 commit into
Open-Legal-Products:mainfrom
eliziff:fix/docx-preserve-text-values

Conversation

@eliziff

@eliziff eliziff commented Aug 13, 2026

Copy link
Copy Markdown

Summary

Prevent numeric-looking Word text runs from being altered when Mike parses or rewrites DOCX files.

Why / Motivation

fast-xml-parser converts element text to JavaScript numbers and booleans by
default. Word stores visible document text in w:t, so a run containing
12.10 becomes 12.1.

This affects text returned by read_document and can rewrite an untouched run
when Mike saves an unrelated tracked edit.

Changes

  • Disable tag-value coercion in the shared DOCX parser.
  • Add regression coverage for extracted text and the rewritten
    word/document.xml.

Tradeoffs & risks

Element text in word/document.xml is now retained as strings, matching how
the DOCX helper consumes it. Attribute parsing, tracked-change IDs, entity
handling, and whitespace behavior are unchanged.

How verified

  • Confirmed the regression test fails on current main, where the rewritten
    w:t contains 12.1.
  • Confirmed the patched output retains 12.10 through an unrelated tracked
    edit.
  • npm test --prefix backend — 551 passed, 23 skipped.
  • npm run build --prefix backend.

Checklist

  • Ran the relevant build and tests.
  • Reviewed the diff and removed unrelated changes.
  • Docs and environment examples are not applicable.
  • No secrets, API keys, real documents, or .env files committed.

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.

1 participant