jsondiffpatch.net icon indicating copy to clipboard operation
jsondiffpatch.net copied to clipboard

`~` and `/` show be replaced in patch path

Open moonheart opened this issue 4 years ago • 1 comments

As rfc6901#section-3 documented, we should replace ~ with ~0 and replace / with ~1.

This is Also the problem I encounted when trying to patch k8s resources, error message: the server rejected our request due to an error in our request.

Json Patch

A JSON Pointer is a Unicode string (see [RFC4627], Section 3) containing a sequence of zero or more reference tokens, each prefixed by a '/' (%x2F) character.

Because the characters '~' (%x7E) and '/' (%x2F) have special meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/' needs to be encoded as '~1' when these characters appear in a reference token.

moonheart avatar Sep 22 '20 14:09 moonheart

Agreed, this is causing a bug in my use case where users legitimately enter values including a '/'.

shochwald-maptek avatar Dec 22 '20 05:12 shochwald-maptek