[fix]: Replace invalid XML characters from cell values during export#399
Open
deeonwuli wants to merge 2 commits into
Open
[fix]: Replace invalid XML characters from cell values during export#399deeonwuli wants to merge 2 commits into
deeonwuli wants to merge 2 commits into
Conversation
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
MiquelAdell
approved these changes
May 21, 2026
eperedo
requested changes
May 25, 2026
| destination.value(Number(value)); | ||
| } else if (String(value).startsWith("=")) { | ||
| destination.formula(String(value)); | ||
| const safeValue = typeof value === "string" ? replaceInvalidXmlChars(value) : value; |
There was a problem hiding this comment.
there is a isString method in string.ts that we can reuse here.
| } else if (String(value).startsWith("=")) { | ||
| destination.formula(String(value)); | ||
| const safeValue = typeof value === "string" ? replaceInvalidXmlChars(value) : value; | ||
| if (!!safeValue && !isNaN(Number(safeValue))) { |
There was a problem hiding this comment.
is the double !! necessary? We can use directly
safeValue && !isNaN(Number(safeValue)))right?
eperedo
requested changes
May 25, 2026
| @@ -5,3 +5,14 @@ export function removeCharacters(value: unknown): string { | |||
| export function isString(value: unknown): value is string { | |||
There was a problem hiding this comment.
I meant this function, not the lodash implementation.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 References
📝 Implementation
Excel-generated
.xlsxfiles fail to open in MS Excel when a DHIS2 string value contains a C0 control character (e.g. vertical tab\x0B), because the xlsx format is XML 1.0 which forbids those bytes.stripInvalidXmlCharsinsrc/utils/string.tsthat replaces invalid XML 1.0 control chars (\x00-\x08,\x0B,\x0C,\x0E-\x1F,\x7F) with a space, preserving the XML-safe whitespace controls (\t,\n,\r).ExcelPopulateRepository.writeCell— so every string value reachingxlsx-populateis safe. Numeric, boolean, formula and defined-name branches are untouched.#869dbc90g