Skip to content

fix: decode JSON Pointer escape sequences - #57

Open
HocVoNgThai wants to merge 1 commit into
fastify:mainfrom
HocVoNgThai:fix/json-pointer-escapes
Open

HocVoNgThai wants to merge 1 commit into
fastify:mainfrom
HocVoNgThai:fix/json-pointer-escapes

Conversation

@HocVoNgThai

Copy link
Copy Markdown

Decode ~1 to / and then ~0 to ~ before looking up each JSON Pointer token. This fixes both direct schema lookup and dereferencing without decoding escaped sequences twice.

For example, #/definitions/order~1count should select the definition named order/count. It currently returns null, or selects the wrong schema if a literal order~1count key also exists. With this change, it selects order/count correctly; a consuming serializer returns {"count":42} instead of {"count":"42"} in the collision case.

Adds regression coverage for slash, tilde, repeated escapes and the ~01 decoding order through getSchema() and getDerefSchema().

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant