From 4ed2c2fcc0b3a4c717c18fd391d688e8278a2080 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sun, 1 Mar 2020 17:42:34 -0500 Subject: [PATCH] json_data: Correct for lost slashes, pre-repair --- src/classes/json_data.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/classes/json_data.py b/src/classes/json_data.py index f23d93bb78..d01a6e6dc2 100644 --- a/src/classes/json_data.py +++ b/src/classes/json_data.py @@ -60,6 +60,9 @@ def __init__(self): # Regular expression matching likely corruption in project files self.damage_re = re.compile(r'/u([0-9a-fA-F]{4})') + # Regular expression used to detect lost slashes, when repairing data + self.slash_repair_re = re.compile(r'(["/][.]+)(/u[0-9a-fA-F]{4})') + # Connection to Qt main window, used in recovery alerts app = get_app() if app: @@ -156,7 +159,8 @@ def read_from_file(self, file_path, path_mode="ignore"): # File contains corruptions, backup and repair self.make_repair_backup(file_path, contents) - # Repair all corrupted escapes + # Repair lost slashes, then fix all corrupted escapes + contents = self.slash_repair_re.sub(r'\1/\2', contents) contents, subs_count = self.damage_re.subn(r'\\u\1', contents) if subs_count < 1: