mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 11:34:43 +08:00
Closes 563: As never defined in RFC 6901 Section 3, do not handle backslashes (\) and quotes(") as anything special
This commit is contained in:
@@ -187,10 +187,11 @@ public class JSONPointer {
|
||||
this.refTokens = new ArrayList<String>(refTokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc6901#section-3
|
||||
*/
|
||||
private static String unescape(String token) {
|
||||
return token.replace("~1", "/").replace("~0", "~")
|
||||
.replace("\\\"", "\"")
|
||||
.replace("\\\\", "\\");
|
||||
return token.replace("~1", "/").replace("~0", "~");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,16 +264,15 @@ public class JSONPointer {
|
||||
/**
|
||||
* Escapes path segment values to an unambiguous form.
|
||||
* The escape char to be inserted is '~'. The chars to be escaped
|
||||
* are ~, which maps to ~0, and /, which maps to ~1. Backslashes
|
||||
* and double quote chars are also escaped.
|
||||
* are ~, which maps to ~0, and /, which maps to ~1.
|
||||
* @param token the JSONPointer segment value to be escaped
|
||||
* @return the escaped value for the token
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc6901#section-3
|
||||
*/
|
||||
private static String escape(String token) {
|
||||
return token.replace("~", "~0")
|
||||
.replace("/", "~1")
|
||||
.replace("\\", "\\\\")
|
||||
.replace("\"", "\\\"");
|
||||
.replace("/", "~1");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user