[utils] Fix js_to_json
Previously, the runtime could be atrocious for longer inputs.
This commit is contained in:
parent
85d5866177
commit
d305dd73a3
2 changed files with 6 additions and 2 deletions
|
@ -1560,8 +1560,8 @@ def js_to_json(code):
|
|||
return '"%s"' % v
|
||||
|
||||
res = re.sub(r'''(?x)
|
||||
"(?:[^"\\]*(?:\\\\|\\")?)*"|
|
||||
'(?:[^'\\]*(?:\\\\|\\')?)*'|
|
||||
"(?:[^"\\]*(?:\\\\|\\['"nu]))*[^"\\]*"|
|
||||
'(?:[^'\\]*(?:\\\\|\\['"nu]))*[^'\\]*'|
|
||||
[a-zA-Z_][.a-zA-Z_0-9]*
|
||||
''', fix_kv, code)
|
||||
res = re.sub(r',(\s*\])', lambda m: m.group(1), res)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue