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

Search for JS() calls recursively only in explicit lists and data.frames #467

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

gadenbuie
Copy link
Collaborator

Fixes #466 by avoids recursion of list-like objects that aren't actually lists, as suggested by @DavisVaughn.

Recursion over data.frames is uncommon but was previously supported and list columns can, in theory, contain JS() code.

The core issue from #466 is the assignment of integers to names(options), which was a clock_calendar object. Casting to character before assignment is safer, but doesn't completely solve the problem and in fact provides further evidence that we should be more selective about recursion becaues cals is infinitely recusable:

cals = clock::year_quarter_day(year = 2000:2001, quarter = 2)
identical(cals[[1]], cals[[1]][[1]])
#> [1] TRUE

In summary, after this change, shouldEval() only enters explicit lists and data.frames to search for JS() (JS_EVAL) objects.

Names are characters, explicitly cast indices to characters
Fixes #466
Avoids recursion of list-like objects that aren't actually lists.
Recursion over data.frames is uncommon but was previously
supported and can, in theory, contain `JS()` calls in list columns.
Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update NEWS and put under a Potential breaking change section (with advice on how to fix the situation)

@gadenbuie gadenbuie merged commit 7c5594a into master Oct 17, 2023
8 checks passed
@gadenbuie gadenbuie deleted the fix/466-shouldEval-recursion branch October 17, 2023 20:08
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.

shouldEval() probably shouldn't recurse over list-like structures that aren't actually lists
2 participants