-
Notifications
You must be signed in to change notification settings - Fork 204
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
Allow setting defaults for SnakeYAML limits #647
Conversation
@oliverbarnes Please verify if you get a chance! |
Having a look 🙏 |
So, I've declared the psych gem with your fork and branch:
And I'm getting the following error when bundling:
The canonical psych gem bundles fine. I'm still investigating if there's something on our end that might cause this somehow, but thought it was worth letting you know. |
So what you're saying I should actually test this, eh? 😝 I'll make some fixes. |
Oh actually I see the problem... JRuby doesn't support installing from Github because we don't build the extension at install time, we build it at build time. So if you build the gem from the fork and install it you should be able to activate it and try it out. |
Ok, cloned the fork and installed the gem from the PR branch:
and configured my app's gemfile to use it.
On the initializer for psych I declared
And when running a spec, I get the following error now:
|
This adds class-level accessors for the following SnakeYAML- specific parser settings: * max_aliases_for_collections * allow_duplicate_keys * allow_recursive_keys * code_point_limit The initial values are based on SnakeYAML Engine's defaults. This PR does not modify those default values. Using these accessors, it should be possible for users to globally change them for all future Psych parser instances without resorting to monkey patches as described in ruby#613 (comment).
c37655a
to
fb97d89
Compare
@oliverbarnes Ooops yup that was on me. I originally planned on storing the non-Ruby object version of these values, and then changed my mind. Unfortunately I didn't change all of the code. Try it with latest version (force pushed)! |
:) seems to be working now. No environment load error, nor any code limit error. I'm now hitting that error from my use case:
described on #648 That's for
not a bad idea 😄 a unit test would be nice, at least |
Only supported on JRuby currently.
I added a test for I tried to add a test for Still looking for good examples for recursive keys and alias limits. |
@asomov Can you point us toward some simple tests for the following settings? I tried to find something in the SnakeYAML Engine repo but have not found anything.
I also tried parsing a simple duplicate key script and it did not error, no matter what setting I provided. foo: bar
foo: bar Should this be rejected? |
👍 thanks, test looks good to me
Maybe worth creating separate PRs? |
Yeah let's go with that idea. |
These settings are not enforced at the parser level in SnakeYAML Engine, instead being enforced during the construction of the YAML node graph. Because the JRuby Psych wrapper around SnakeYAML only uses the parser directly, the settings have no effect. This commit removes the ineffective settings until we can decide what to do about them. See ruby#613, ruby#647, and ruby#649.
This adds class-level accessors for the following SnakeYAML-specific parser settings:
The initial values are based on SnakeYAML Engine's defaults. This PR does not modify those default values.
Using these accessors, it should be possible for users to globally change them for all future Psych parser instances without resorting to monkey patches as described in #613 (comment).