Skip to content

Commit

Permalink
Merge branch 'osp-file-repair' into release-20200229
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Mar 1, 2020
2 parents f792a4a + 4ed2c2f commit df8baf0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/classes/json_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit df8baf0

Please sign in to comment.