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

Fix precedent cells incorrectly accepting file references #2162

Closed
wants to merge 1 commit into from

Conversation

sbeca
Copy link
Contributor

@sbeca sbeca commented Sep 9, 2023

Today I came across a bug that caused a stack overflow and crashed my app. One of my test spreadsheets had a cell '10.Livestock'!X122 with a formula of =-'[1]10.Livestock'!X122 and with the latest code of ClosedXML from Git, this caused my crash.

I know that ClosedXML doesn't currently support file references, and has previously rejected them with a NotImplementedException. With latest HEAD though, the new PrecedentCells code was ignoring the file reference prefix entirely, resulting in the cell '10.Livestock'!X122 basically looking like it had formula of =-'10.Livestock'!X122, at least for the code that works out the precedent cells. With a certain setup where the value is out of date, this can cause the precedent cell code to get into an infinite recursion loop, overflowing the stack and crashing the app.

This PR updates the precedent cell code to use a different method of getting the worksheet which checks for file references and throws an exception if detected, which matches up with what the calculation code does. It also adds a new test to make sure that file references are always rejected.

@jahav
Copy link
Member

jahav commented Sep 9, 2023

@sbeca I am currently working to replace the the current recursive dependency resolution with standard (see Excel Recalculation) dependency tree and calculation chain (#2155, #2156, #2160) and it's a blocker for releasing 0.103.

I definitely have to add tests to new precedent visitor, thanks.

Since the XLCalcEngine will be deleted that will be deleted in the before 0.103 is released, I don't think it makes sense to merge the PR and I am closing it 🙇.

@jahav jahav closed this Sep 9, 2023
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.

None yet

2 participants