Repository navigation
fix(sheet): escape hex sequences in in-memory XLSX writes too - #1223
Open
Sean-Walker0 wants to merge 1 commit into
Open
Sean-Walker0 wants to merge 1 commit into
Sean-Walker0 wants to merge 1 commit into
Conversation
EscapeHexCellWriteHandler, registered by default for XLSX writes, guarded on cell instanceof SXSSFCell and therefore skipped in-memory (XSSFCell) writes entirely: with inMemory(true) a literal _xHHHH_ sequence was stored unescaped and POI's reader decoded it to the character it names, so "_xB9f0_ and _x1234_" round-tripped as "\uB9f0 and \u1234" instead of the literal the caller wrote. Accept both OOXML cell kinds, SXSSFCell and XSSFCell. XLS (HSSFCell) and CSV (CsvCell) keep being skipped: they have no _xHHHH_ decoding, so escaping there would corrupt literals - which is exactly what the existing across-formats round-trip test pins. Verified with EscapeHexInMemoryWriteTest (the in-memory case corrupts before the change and passes after; the streaming case pins the default-handler path on both sides) plus the untouched existing escape tests, the full fesod-sheet suite (1049 tests) and spotless:check.
Sean-Walker0
force-pushed
the
fix/inmemory-xlsx-hex-escape
branch
from
October 15, 2026 06:45
0243d38 to
218ee56
Compare
3 tasks done
This branch has not been deployed
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.
Purpose of the pull request
EscapeHexCellWriteHandleris registered by default for XLSX writes to keep literal_xHHHH_sequences intact across a round trip. Its guard requiredcell instanceof SXSSFCell, so in-memory writes (inMemory(true), whose cells areXSSFCell) were skipped entirely and a literal sequence was stored unescaped: POI's reader decodes_xHHHH_to the character it names, so"_xB9f0_ and _x1234_"round-tripped as"맰 and ሴ"— silent data corruption on exactly the mode users pick when they need POI features that streaming does not support.No issue exists for this yet; found while reviewing the default handler set.
What's changed?
The guard now accepts both OOXML cell kinds,
SXSSFCell(streaming) andXSSFCell(in-memory). XLS (HSSFCell) and CSV (CsvCell) keep being skipped on purpose: they have no_xHHHH_decoding, so escaping there would corrupt literals — which is exactly what the existing across-formats round-trip test pins, and those tests pass untouched.Checklist
Verifying this change
EscapeHexInMemoryWriteTest(default handler registration, no explicit handler):inMemoryWriteRoundTripsLiteralEscapeSequences— red before (expected: <_xB9f0_ and _x1234_> but was: <맰 and ሴ>), green after;streamingWriteRoundTripsLiteralEscapeSequences— pins the default-handler streaming path, green before and after.Existing escape tests (
EscapeHexCellWriteHandlerTest19 cases incl. the HSSFCell skip pin,EscapeHexCellWriteHandlerRoundTripTestacross XLSX/XLS/CSV): all pass unmodified../mvnw clean package -B -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 1049 tests, 0 failures, 0 errors../mvnw -pl fesod-sheet spotless:check: clean.Notes
_xHHHH_literals like streaming writes do. Writers whose literal files intentionally contain decodable_xHHHH_(relying on the previous in-memory leak) would see them preserved instead of decoded — that preservation is the handler's documented purpose.setCellValueoutside theafterCellDataConvertedhook, so they are never escaped in any mode. Fixing that spans the head and fill write paths and seemed worth its own discussion rather than folding into this fix.EscapeHexCellWriteHandler; the two open PRs touchingDefaultWriteHandlerLoader(refactor: Improve the basic javadoc content #1181 javadoc, feat: add support for ODS file format with read/write capabilities #745 ODS case) do not overlap this file.