-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Invalid RFC6902 copy operation succeeds #894
Comments
Thanks for noting! I could fix this issue by implementing the copy operation similar to the move operation: const std::string from_path = get_value("copy", "from", true);
const json_pointer from_ptr(from_path);
// the "from" location must exist - use at()
basic_json v = result.at(from_ptr);
// The copy is functionally identical to an "add"
// operation at the target location using the value
// specified in the "from" member.
operation_add(ptr, v); I was just about to commit the change when I realized the library currently fails some tests from https://github.com/json-patch/json-patch-tests - some even trigger assertions. I shall have a look at these failing tests and see if I can fix these problems as well. |
Thanks for the rapid response! |
The test suite revealed another problem: we did not check if we completely parsed an array index. For instance, |
- Implemented "copy" in terms of "add". - Added check for JSON Pointer array indices to make sure the complete reference token was processed. - Added test suite from https://github.com/json-patch/json-patch-tests
@cmannett85 Could you check whether the |
Using my trivial example above, I now get:
Which is expected - thank you! |
The above "move" and "copy" JSON patch operations are both invalid for the same reason:
/a/b/c
is an invalid path becauseb
does not already exist - however, the "copy" succeeds.Legalise:
RFC6902 4.5:
RFC6092 4.1:
The text was updated successfully, but these errors were encountered: