Description
findValOfKey in tests/e2e/common.go extracts JSON values using a regex:
keystr := "\"" + key + "\":[^,;\\]}]*"
The character class [^,;\\]}]* stops at the first comma, semicolon, ], or }. This silently truncates any value containing those characters, returning wrong data without any error.
Steps to Reproduce
cd /mnt/c/Users/alikh/Desktop/Projects/urunc_test
go test ./tests/e2e/ -run TestFindValOfKey -v
Output:
Expected Behavior
findValOfKey should return the correct value for any valid JSON, regardless of value complexity.
Current Behavior
The regex stops at the first comma inside a string value ("foo,bar" → foo) and at the first } in a nested object, then the split-on-colon further mangles the result ({"IPAddress":"172.17.0.2"} → {IPAddress).
Proposed Solution
Replace the regex with encoding/json unmarshalling and a recursive key search.
Description
findValOfKeyintests/e2e/common.goextracts JSON values using a regex:The character class
[^,;\\]}]*stops at the first comma, semicolon,], or}. This silently truncates any value containing those characters, returning wrong data without any error.Steps to Reproduce
Output:
Expected Behavior
findValOfKeyshould return the correct value for any valid JSON, regardless of value complexity.Current Behavior
The regex stops at the first comma inside a string value (
"foo,bar"→foo) and at the first}in a nested object, then the split-on-colon further mangles the result ({"IPAddress":"172.17.0.2"}→{IPAddress).Proposed Solution
Replace the regex with
encoding/jsonunmarshalling and a recursive key search.