trim trailing null from callout script get-attributes output#85
Merged
jonner merged 1 commit intoApr 5, 2023
Merged
Conversation
53b2823 to
5b7e6f5
Compare
Member
|
Consider adding a test while we're at it. For example, something like this could be squashed into your patch: diff --git a/src/tests.rs b/src/tests.rs
index 215ff2a..a98b5c5 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -1959,6 +1959,16 @@ fn test_callouts() {
test.populate_callout_script("good-json.sh");
},
);
+ test_get_callout(
+ "test_callout_good_json_null",
+ Expect::Pass,
+ Uuid::parse_str(DEFAULT_UUID).unwrap(),
+ DEFAULT_PARENT,
+ DEFAULT_TYPE,
+ |test| {
+ test.populate_callout_script("good-json-null-terminated.sh");
+ },
+ );
test_get_callout(
"test_callout_bad_json",
Expect::Fail(None),
diff --git a/tests/callouts/good-json-null-terminated.sh b/tests/callouts/good-json-null-terminated.sh
new file mode 100755
index 0000000..c5e12d7
--- /dev/null
+++ b/tests/callouts/good-json-null-terminated.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo -ne "[{\"attribute0\": \"VALUE\"}]\0" |
Contributor
Author
|
Fair point. Thanks for providing this. |
Contributor
Author
|
Would you like for me to add your sign-off to the patch since you provided the test case? |
Member
|
I suppose that would probably be more proper, why not. |
Member
A trailing null will make serde_json::from_str fail. Let's trim the string if a null is present to make it happy. Fixes mdevctl#84 Signed-off-by: Collin Walling <walling@linux.ibm.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
5b7e6f5 to
f5f7694
Compare
Contributor
Author
|
Fixed up. Thanks @jonner |
Member
|
Let's just merge this and rebase #83 if necessary. That one is going to take more time to review. |
Contributor
Author
|
Sure. Boris is out-of-office for a while. Any suggestions on how I can handle rebasing his branch? Is it as simple as forking his changes, rebasing, then creating a new PR? /shrug. |
Member
|
I think I might have the ability (as maintainer) to edit his PR branch. So maybe I could rebase it and force push. Otherwise we can figure it out later ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A trailing null will make serde_json::from_str fail. Let's trim the string if a null is present to make it happy.
Fixes #84
Note, this will create a merge conflict in PR #83. If this change is acceptable, I can either rebase Boris' patches on top of this, or I can fit this patch in nicely after the conflicting commit.