Skip to content

Commit

Permalink
fixed empty object bug reported by @Tare05
Browse files Browse the repository at this point in the history
the exact same problem as 062c43f
but with objects instead of lists
  • Loading branch information
dnet committed Feb 6, 2020
1 parent 48ed425 commit b19bd74
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ private void escapeUrlEncodedBytes(byte[] input, StringBuilder output,

private static void escapeJson(Json node, StringBuilder output) {
if (node.isObject()) {
String prefix = "{";
output.append('{');
Map<String, Json> tm = new TreeMap(String.CASE_INSENSITIVE_ORDER);
tm.putAll(node.asJsonMap());
for (Map.Entry<String, Json> e : tm.entrySet()) {
output.append(prefix);
prefix = ", ";
escapeString(e.getKey(), output);
output.append(": ");
escapeJson(e.getValue(), output);
final Iterator<Map.Entry<String, Json>> iter = tm.entrySet().iterator();
if (iter.hasNext()) {
appendIteratedEntry(iter, output);
while (iter.hasNext()) {
output.append(", ");
appendIteratedEntry(iter, output);
}
}
output.append('}');
} else if (node.isArray()) {
Expand All @@ -252,6 +253,13 @@ private static void escapeJson(Json node, StringBuilder output) {
}
}

private static void appendIteratedEntry(Iterator<Map.Entry<String, Json>> iter, StringBuilder output) {
final Map.Entry<String, Json> e = iter.next();
escapeString(e.getKey(), output);
output.append(": ");
escapeJson(e.getValue(), output);
}

private static String byteSliceToString(byte[] input, int from, int till) {
try {
return new String(input, from, till - from, "ISO-8859-1");
Expand Down

0 comments on commit b19bd74

Please sign in to comment.