Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ static void addPatches(
String basePath,
Map<String, String> current,
Map<String, String> required) {

for (String name : required.keySet()) {
// We must encode each '/' and '~' in a JSON patch token using '~1' and '~0', otherwise
// the JSON patch will incorrectly treat '/' and '~' as special delimiters. (RFC 6901).
// The resulting patched JSON will have '/' and '~' within the token (not ~0 or ~1).
String encodedPath = basePath + name.replace("~","~0").replace("/","~1");
if (!current.containsKey(name)) {
patchBuilder.add(basePath + name, required.get(name));
patchBuilder.add(encodedPath, required.get(name));
} else {
patchBuilder.replace(basePath + name, required.get(name));
patchBuilder.replace(encodedPath, required.get(name));
}
}
}
Expand Down