Skip to content

Fixes a potential stack overflow if the object graph contains cycles#340

Merged
xoofx merged 1 commit intoscriban:masterfrom
NeilMacMullen:fix-potential-stackoverflow
Apr 17, 2021
Merged

Fixes a potential stack overflow if the object graph contains cycles#340
xoofx merged 1 commit intoscriban:masterfrom
NeilMacMullen:fix-potential-stackoverflow

Conversation

@NeilMacMullen
Copy link
Copy Markdown
Contributor

It's unfortunately quite easy to create cyclical object graphs in TextrudeInteractive since the script is re-rendered after each keystroke. For example, en-route to typing model.newProperty=model.a+model.b the user will, at some point, have a line reading model.newProperty=model. If this is then rendered to a string, Scriban will throw an uncatchable StackOverflowException as it repeatedly traverses TemplateContext.ObjectToString and ScriptObject.ToString.

This change introduces an ObjectRecursionLimit property on TemplateContext which is checked against the existing _objectToStringLevel field. It defaults to 0 (i.e disabled) to preserve the old behaviour unless explicitly set.

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.

2 participants