feat: allow reviving user types from saves without eval#388
Open
io-spectre wants to merge 2 commits intotmedwards:developfrom
Open
feat: allow reviving user types from saves without eval#388io-spectre wants to merge 2 commits intotmedwards:developfrom
eval#388io-spectre wants to merge 2 commits intotmedwards:developfrom
Conversation
Add a replacement for `Serial.createReviver()` which does not evaluate code contained in a save file.
f5f7336 to
7b13ec6
Compare
Author
|
btw. why is there support for |
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.
It is quite common for authors to accept (or even require) save files for bug reports. Therefore we should allow authors to completely opt-out of executing arbitrary code on save load. This is implemented here by introducing
Config.saves.isEvalEnabled(which currently defaults to true).I've implemented a simple somewhat-more-explicit method for reviving user types which does not need
eval-like powers by using a registry-based dispatch mechanism:1I'm open to bike-shedding and if I've violated some sort of style guide, please let me know. I'll fix it asap.
Resolves #390
Footnotes
The mechanism could be extended to automatically detect a registered serializer based on the prototype, etc. but I thought this minimal equivalent feature set to be less controversial. ↩