Skip to content

jsonpointer should not expect pointers to be urlencoded #22

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

Closed
stefankoegl opened this issue Sep 19, 2017 · 1 comment
Closed

jsonpointer should not expect pointers to be urlencoded #22

stefankoegl opened this issue Sep 19, 2017 · 1 comment

Comments

@stefankoegl
Copy link
Owner

As pointed out by @mithrandi in stefankoegl/python-json-patch#63:

The first problem is that jsonpointer expects pointers to be urlencoded, which I don't think is correct
(my reading of the RFC is that urlencoding should only be used when the pointer is part of a URL, so
nothing special to JSON pointer itself).

My response within the referenced issue

[...] the failing example should be

>>> import jsonpointer
>>> obj = {'a b': 1}
>>> jsonpointer.resolve_pointer(obj, '/a%20b')
1

Instead this should give an error because there is no member a%20b.

It seems that I added the unquoting (currently
line 145) already in the very first commit.
Initially the [RFC draft|https://tools.ietf.org/html/draft-pbryan-zyp-json-pointer-00] did contain

Property names SHOULD be URI encoded per [RFC2396]. In particular,
any "/" character in a property name MUST be encoded as "%2F" to
avoid being interpreted as a property reference token separator.

but this was removed before the final RFC, and is thus no longer correct.

@anentropic
Copy link

I wondered about this when reading the docs:
https://python-json-pointer.readthedocs.io/en/latest/tutorial.html

>>> from jsonpointer import resolve_pointer
>>> obj = {"foo": {"anArray": [ {"prop": 44}], "another prop": {"baz": "A string" }}}

>>> resolve_pointer(obj, '/foo/another%20prop') == obj['foo']['another prop']
True

It seems like this was fixed and urlencoding is not required, do the docs need updating?

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

No branches or pull requests

2 participants