Skip to content

jsonpointer should not expect pointers to be urlencoded #22

Closed
@stefankoegl

Description

@stefankoegl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions