Skip to content

Fix formula text truncated on XML character references - #348

Merged
MathNya merged 1 commit into
MathNya:masterfrom
sentinelt:fix/data-validation-formula-char-refs
Jul 28, 2026
Merged

Fix formula text truncated on XML character references#348
MathNya merged 1 commit into
MathNya:masterfrom
sentinelt:fix/data-validation-formula-char-refs

Conversation

@sentinelt

@sentinelt sentinelt commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

dataValidation / formula character data that contains XML numeric character references (e.g. – for an en-dash) was truncated when reading .xlsx files.

Root cause

quick-xml emits those references as Event::GeneralRef nodes between successive Event::Text fragments. The parsers for DataValidation (formula1 / formula2) and Formula replaced the accumulator on each Text event and ignored GeneralRef, so only the last text fragment survived.

Example list formula in a real workbook:

<formula1>"0&#8211;3 years ago,4&#8211;5 years ago,6&#8211;7 years ago"</formula1>

was read as:

7 years ago"

instead of the full list string.

Fix

  • Append successive Text events instead of overwriting
  • Resolve and append GeneralRef (numeric char refs + common named entities)
  • Shared helpers: append_xml_text / append_xml_general_ref
  • Unit tests covering en-dash list formulas and plain list formulas
  • Close a missing brace in number_formater tests that broke compilation of the local tree

quick-xml emits numeric character references (e.g. &#8211;) as GeneralRef
events between Text fragments. DataValidation and Formula parsers replaced
the accumulator on each Text event and ignored GeneralRef, so list
formulas were truncated to the last fragment. Append Text and GeneralRef
instead, with unit coverage for en-dash list formulas.

Also close a missing brace in number_formater tests that broke compilation.
@MathNya

MathNya commented Jul 28, 2026

Copy link
Copy Markdown
Owner

@sentinelt
Thank you for the PR.
Since there were no issues with the changes, I’ll go ahead and merge them.
(I’ll make a few minor adjustments after merging.)

There are a few other instances of this, so it looks like we’ll need to review the entire code.

@MathNya
MathNya merged commit 461dc05 into MathNya:master Jul 28, 2026
@c-git

c-git commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@MathNya after you've done the update in the other places as well, please let me know so I can test if it also fixes my issue in #336

@MathNya

MathNya commented Aug 4, 2026

Copy link
Copy Markdown
Owner

@c-git
We have addressed all the issues.
Please check #336.

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