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

Do not expose internal state in the public encoder API (i.e. as_json) #12785

Merged
merged 2 commits into from Nov 7, 2013

Conversation

Projects
None yet
2 participants
@chancancode
Member

chancancode commented Nov 6, 2013

See 1 for why this is not a good idea.

As part of this refactor, circular reference protection in as_json has
been removed and the corresponding error class has been deprecated.

As discussed with @jeremy, circular reference error is considered
programmer errors and protecting against it is out of scope for
the encoder.

This is again based on the excellent work by @sergiocampama in #11728.

@jeremy

View changes

Show outdated Hide outdated activesupport/lib/active_support/core_ext/object/json.rb Outdated

@ghost ghost assigned jeremy Nov 6, 2013

@jeremy

View changes

Show outdated Hide outdated activesupport/lib/active_support/core_ext/object/json.rb Outdated
@jeremy

View changes

Show outdated Hide outdated activesupport/lib/active_support/json/encoding.rb Outdated
"For example, the following Hash contains a circular reference to itself:\n" \
" h = {}\n" \
" h['circular'] = h\n" \
"In this case, calling h.to_json would not work properly."

This comment has been minimized.

@jeremy

jeremy Nov 7, 2013

Member

ActiveSupport::JSON.encode

@jeremy

jeremy Nov 7, 2013

Member

ActiveSupport::JSON.encode

chancancode added some commits Nov 6, 2013

Do not expose internal state in the public encoder API (i.e. as_json)
See [1] for why this is not a good idea.

As part of this refactor, circular reference protection in as_json has
been removed and the corresponding error class has been deprecated.

As discussed with @jeremy, circular reference error is considered
programmer errors and protecting against it is out of scope for
the encoder.

This is again based on the excellent work by @sergiocampama in #11728.

[1]: intridea/multi_json#138 (comment)

jeremy added a commit that referenced this pull request Nov 7, 2013

Merge pull request #12785 from chancancode/do_not_leak_internal_state
Do not expose internal state in the public encoder API (i.e. as_json)

@jeremy jeremy merged commit 240863a into rails:master Nov 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment