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

Remove opportunistic loading of yajl/json_gem #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jnraine
Copy link

@jnraine jnraine commented Dec 24, 2018

Requiring yajl/json_gem causes JSON.parse, JSON.generate, #to_json, and other built-in methods to be overridden with the faster YAJL implementation. Faster is, as a rule, better so this seems like a positive change overall. However, because this change extends outside of gelf-rb and impacts any place JSON is parsed or generated using the standard library interface, it can have surprising and unexpected consequences.

When I updated gelf-rb to version 3.1.0, parts of my app started to behave differently. Specifically, U+2028 and U+2029 characters stopped being escaped within JSON strings. For a Rails app, which already overrides the standard library interface, this can be a problem [1]. (This will only impact folks who use YAJL without require 'yajl/json_gem'.)

To remedy this, yajl/json_gem is no longer required by default. This makes the optimization of JSON parsing the responsibility of the app/script/person requiring gelf-rb.

[1] http://timelessrepo.com/json-isnt-a-javascript-subset

Requiring `yajl/json_gem` causes `JSON.parse`, `JSON.generate`, `#to_json`, and others built-in methods to be overridden with the faster YAJL implementation. Faster is, as a rule, better so this seems like a positive change overall. However, because this change extends outside of `gelf-rb` and impacts any place JSON is parsed or generated using the standard library interface, it can have surprising and unexpected consequences.

When I updated gelf-rb to version 3.1.0, parts of my app started to behave differently. Specifically, U+2028 and U+2029 characters stopped being escaped within JSON strings. For a Rails app, this can be a problem [1]. (This will only impact folks who use YAJL without `require 'yajl/json_gem'`.)

To remedy this, `yajl/json_gem` is no longer required by default. This makes the optimization of JSON parsing the responsibility of the app/script/person requiring `gelf-rb`.

[1] http://timelessrepo.com/json-isnt-a-javascript-subset
@CLAassistant
Copy link

CLAassistant commented Dec 24, 2018

CLA assistant check
All committers have signed the CLA.

@jnraine
Copy link
Author

jnraine commented May 21, 2019

@AlekSi does this seem like a change useful to the project? Right now, we maintain an empty file to make sure yajl/json_gem isn't loaded when graylog-rb is required. 😅

@AlekSi
Copy link
Contributor

AlekSi commented May 21, 2019

I have no idea, I stopped maintaining this gem (and using it, and using Ruby) years ago.

@farvour
Copy link

farvour commented Mar 4, 2020

Well, perhaps it would be a good idea to merge the change? Does anyone else have the ability to merge this in? @AlekSi ? That would be nice. "I don't know, I don't maintain this" is very unhelpful and results in a bunch of useless forks getting created for a project. The impact of this change is pretty significant and I think merging this would make 3.1.x usable for a wider audience.

@AlekSi
Copy link
Contributor

AlekSi commented Mar 5, 2020

I don't have access to merge this change. I'm not a maintainer for a long time already. Sorry.

/cc @lennartkoopmann

@farvour
Copy link

farvour commented Mar 5, 2020 via email

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.

4 participants