Skip to content

Commit 3d17927

Browse files
Merge pull request #1107 from solidify/feature/non-unicode-chars
Handle uncode escape sequence in migration files, warn about non-unicode characters
2 parents 8daa3d7 + fa955ab commit 3d17927

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WorkItemMigrator/Migration.WIContract/WiItemProvider.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ private WiItem LoadFile(string path)
3232
serialized = Regex.Replace(serialized, @"\\\\u[0-F]{4,}", "");
3333
}
3434

35+
serialized = serialized.Replace("\\u001b", "\n"); // Clean up Unicode escape characters
36+
3537
var deserialized = JsonConvert.DeserializeObject<WiItem>(serialized, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
3638

3739
foreach (var rev in deserialized.Revisions)
@@ -59,7 +61,9 @@ public IEnumerable<WiItem> EnumerateAllItems()
5961
}
6062
catch (Exception)
6163
{
62-
Logger.Log(LogLevel.Warning, $"Failed to load '{Path.GetFileName(filePath)}' (perhaps not a migration file?).");
64+
Logger.Log(LogLevel.Warning, $"Failed to load '{Path.GetFileName(filePath)}', possible reasons:\n " +
65+
$"- Perhaps not a migration file?\n " +
66+
$"- Perhaps the file contains unhandled Unicode sequences (e.g. \\u1234, \\uXXXX) or non-unicode characters? Invalid characters must be stripped.");
6367
}
6468
}
6569
return result;

0 commit comments

Comments
 (0)