Commit 69b520c1 authored by Mateusz Pawlik's avatar Mateusz Pawlik

Added removal of the null character.

Weird stuff that caused errors in parsing bracket notation in C++.
parent 3a6c0e07
...@@ -14,7 +14,9 @@ import json ...@@ -14,7 +14,9 @@ import json
def print_tree(json_tree, index): def print_tree(json_tree, index):
print('{' + json_tree[index]['type'], end='') print('{' + json_tree[index]['type'], end='')
if 'value' in json_tree[index]: if 'value' in json_tree[index]:
print('{' + json_tree[index]['value'].replace('\r','').replace('\n','').replace('\t', '').strip().translate(str.maketrans({"{": r"\{", # \x00 is a null character (https://en.wikipedia.org/wiki/Null_character)
# it caused endless loop / SEGFAULT while parsing a tree in bracket notation
print('{' + json_tree[index]['value'].replace('\r','').replace('\n','').replace('\t', '').replace('\x00', '').strip().translate(str.maketrans({"{": r"\{",
"}": r"\}", "}": r"\}",
"\\": r"\\"})) "\\": r"\\"}))
+ '}', end='') + '}', end='')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment