Rev1529, Fix json write bug with [] characters in value

This commit is contained in:
shortcutme 2016-09-29 13:01:02 +02:00
parent 6a58083431
commit d760a71b76
2 changed files with 9 additions and 3 deletions

View File

@ -8,7 +8,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.4.1"
self.rev = 1527
self.rev = 1529
self.argv = argv
self.action = None
self.config_file = "zeronet.conf"

View File

@ -236,10 +236,16 @@ class SiteStorage(object):
# Make it a little more compact by removing unnecessary white space
def compact_list(match):
return "[ " + match.group(1).strip() + " ]"
if "\n" in match.group(1):
return "[ " + match.group(1).strip() + " ]"
else:
return match.group(0)
def compact_dict(match):
return "{ " + match.group(1).strip() + " }"
if "\n" in match.group(1):
return "{ " + match.group(1).strip() + " }"
else:
return match.group(0)
content = re.sub("\[([^,\{\[]{10,100}?)\]", compact_list, content, flags=re.DOTALL)
content = re.sub("\{([^,\[\{]{10,100}?)\}", compact_dict, content, flags=re.DOTALL)