Open dannyp303 opened 1 year ago
So, to be clear, the issue is that the Java components emit JSON without escaping strings in the generated JSON, right? I want to clarify that we're talking about generating JSON and not parsing it so I can be sure I'm thinking about this right.
If so, a band-aid sort of fix is probably something like this (modified based on this):
return s.replace("\\", "\\\\") // Must escape slash first
.replace("/", "\\/")
.replace("\t", "\\t")
.replace("\b", "\\b")
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("\f", "\\f")
.replace("\"", "\\\"");
The JSON Implementation in the ofrak_ghidra components does not consider control characters in JSON output.
In my case, attempting to send string data recovered from a binary with newline (\n) characters produces:
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 31 (char 30)
Ghidra has it's own JSON parser with about zero documentation: https://ghidra.re/ghidra_docs/api/generic/json/JSONParser.html
And only some people using it to parse json, not construct one: https://github.com/NationalSecurityAgency/ghidra/issues/1982