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

JsonPointer.appendProperty(String) does not escape the property name #1145

Closed
Mahoney opened this issue Nov 24, 2023 · 3 comments
Closed

JsonPointer.appendProperty(String) does not escape the property name #1145

Mahoney opened this issue Nov 24, 2023 · 3 comments
Labels
2.17 Issues planned (at earliest) for 2.17
Milestone

Comments

@Mahoney
Copy link

Mahoney commented Nov 24, 2023

The following code:

JsonPointer
  .valueOf("/")
  .appendProperty("paths")
  .appendProperty("/things")
  .appendProperty("post")
  .appendProperty("requestBody")
  .appendProperty("content")
  .appendProperty("application/json")
  .appendProperty("schema")

should produce this json pointer:
/paths/~1things/post/requestBody/content/application~1json/schema

Instead it produces this json pointer:
/paths/things/post/requestBody/content/application/json/schema

As you can see, the / at the start of /things and the / in the middle of application/json are not escaped, producing a completely incorrect path.

(You also need to escape ~ correctly as per RFC 69010

@Mahoney
Copy link
Author

Mahoney commented Nov 24, 2023

(Incidentally, wouldn't it make sense to have a JsonPointer.ROOT constant that evaluates to JsonPointer.valueOf("/")?)

@cowtowncoder
Copy link
Member

cowtowncoder commented Dec 13, 2023

@Mahoney Escaping part does look like a straight bug, yes.

As to JsonPointer for "/": no, semantics are such that "/" is for matching root level property with "empty" name like:

{ "" : 42 }

as opposed to representing root value itself.

"Root" pointer, however, exists as JsonPointer.empty() and is created for empty String.

@cowtowncoder cowtowncoder added the 2.17 Issues planned (at earliest) for 2.17 label Dec 15, 2023
@cowtowncoder cowtowncoder added this to the 2.17.0 milestone Dec 15, 2023
@cowtowncoder
Copy link
Member

Due to change in observed behavior, fixing in 2.17 for next minor release (2.17.0), cannot backport into 2.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.17 Issues planned (at earliest) for 2.17
Projects
None yet
Development

No branches or pull requests

2 participants