Escape ~ and / in JSONPointer.toURIFragment()
toURIFragment() URL-encoded each reference token but skipped the ~0/~1 escaping from RFC 6901. Tokens are stored as literal key names, so a key containing / or ~ produced a fragment that parsed back to a different pointer. Apply escape() before encoding, as toString() already does. Fixes #1082
This commit is contained in:
@@ -276,7 +276,7 @@ public class JSONPointer {
|
||||
try {
|
||||
StringBuilder rval = new StringBuilder("#");
|
||||
for (String token : this.refTokens) {
|
||||
rval.append('/').append(URLEncoder.encode(token, ENCODING));
|
||||
rval.append('/').append(URLEncoder.encode(escape(token), ENCODING));
|
||||
}
|
||||
return rval.toString();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
||||
Reference in New Issue
Block a user