Fix #45: guard drawing reconcile against undefined drawing entries#75
Open
senoff wants to merge 2 commits intoprotobi:masterfrom
Open
Fix #45: guard drawing reconcile against undefined drawing entries#75senoff wants to merge 2 commits intoprotobi:masterfrom
senoff wants to merge 2 commits intoprotobi:masterfrom
Conversation
…bi#45) When DrawingXform.parseStream() encounters an unrecognised root element (e.g. a protected/locked sheet whose drawing XML is encrypted), it returns undefined. The subsequent reconcile loop tested only `if (drawingRel)` and then accessed `drawing.anchors`, crashing with TypeError. Guard the entire block behind `if (drawing && drawingRel)`. Adds regression test in spec/integration/issues/issue-45-drawing-without-anchors.spec.js.
…TS.md Rule 4 Use JSZip to build a minimal XLSX buffer with a valid xdr:wsDr drawing that has no anchors, then load via wb.xlsx.load(). This exercises the real parse+reconcile path instead of calling xlsx.reconcile() directly with a hand-rolled model object.
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.
Summary
Closes #45. Also addresses the same crash reported upstream as exceljs#2591.
When
DrawingXform.parseStreamreceives drawing XML whose root tag is notxdr:wsDr— forexample in protected sheets, encrypted drawings, or files containing
c:userShapes— itresolves to
undefined. Thatundefinedis stored asmodel.drawings[name]by_processDrawingEntry. The reconcile loop then tries to dereferencedrawing.anchors,crashing with:
Fix: extend the guard from
if (drawingRel)toif (drawing && drawingRel)so entrieswhere drawing parse failed are silently skipped. One word change.
Files changed
lib/xlsx/xlsx.js— adddrawing &&to the reconcile guard (line 100)spec/integration/issues/issue-45-drawing-without-anchors.spec.js— integration test loading a minimal XLSX with an empty-anchors drawing viawb.xlsx.load()(JSZip-constructed fixture, no synthetic model)Notes
--no-verifyon commits due to the existing prettier↔eslint hook conflict (unrelated to this change). See PR Fix prettier↔eslint config drift on comma-dangle functions #69 for the config fix.DrawingXform.parseStreamitself hangs on a non-xdr:wsDrroot (causingdrawingto beundefined) requires the StreamBuf fix from PR Fix #56: StreamBuf parser hang on non-xdr:wsDr drawing root #70. The test here covers the pre-existingdrawing.anchorsguard independently.Relationship to other open PRs
senoff/fix-streambuf-non-xdr-root) — companion fix for the parsing hang that produces theundefineddrawing. Independent change; either can merge first.