Skip to content

Commit 4ed2c2f

Browse files
committed
json_data: Correct for lost slashes, pre-repair
1 parent 777cf1f commit 4ed2c2f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/classes/json_data.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def __init__(self):
6060
# Regular expression matching likely corruption in project files
6161
self.damage_re = re.compile(r'/u([0-9a-fA-F]{4})')
6262

63+
# Regular expression used to detect lost slashes, when repairing data
64+
self.slash_repair_re = re.compile(r'(["/][.]+)(/u[0-9a-fA-F]{4})')
65+
6366
# Connection to Qt main window, used in recovery alerts
6467
app = get_app()
6568
if app:
@@ -156,7 +159,8 @@ def read_from_file(self, file_path, path_mode="ignore"):
156159
# File contains corruptions, backup and repair
157160
self.make_repair_backup(file_path, contents)
158161

159-
# Repair all corrupted escapes
162+
# Repair lost slashes, then fix all corrupted escapes
163+
contents = self.slash_repair_re.sub(r'\1/\2', contents)
160164
contents, subs_count = self.damage_re.subn(r'\\u\1', contents)
161165

162166
if subs_count < 1:

0 commit comments

Comments
 (0)