Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't break when attempting to import a zip file that's not an Excel file (eg. .numbers) #423

Merged
merged 2 commits into from Nov 20, 2017

Conversation

@papandreou
Copy link
Contributor

commented Oct 18, 2017

Hi!

We're running a service that uses exceljs to process uploaded Excel spreadsheets. The other day a user accidentally uploaded a wrongly named .numbers file, which caused an exceljs crash:

     TypeError: Cannot read property 'reduce' of undefined
      at module.exports.reconcile (dist/es5/xlsx/xform/book/workbook-xform.js:145:34)
      at module.exports.reconcile (dist/es5/xlsx/xlsx.js:85:19)
      at dist/es5/xlsx/xlsx.js:316:14

I had a quick look, and it seems like .numbers files also use a zip-based container, but since all the entries are differently named compared to .xlsx, some internal state ends up being unintialized, which makes reconcile break.

Turns out it was rather easy to just default that state so the file loads, but isn't populated with any worksheets. It would probably be better to reject the promise with a specific error, though. What do you think?

@papandreou

This comment has been minimized.

Copy link
Contributor Author

commented Nov 6, 2017

@guyonroche

This comment has been minimized.

Copy link
Collaborator

commented Nov 20, 2017

Hey Guys,
Finally I have some time to catch up on excel stuff. This looks good - non breaking benign kind of change so I'm happy to include it. Will try to publish some time this week

@guyonroche guyonroche merged commit 8300ebb into exceljs:master Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.