Skip to content

Commit

Permalink
handle additional whitespace in Failure
Browse files Browse the repository at this point in the history
  • Loading branch information
rkm committed Aug 24, 2023
1 parent e8e0d2b commit 7cc0145
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions IsIdentifiable/Reporting/Reports/FailureStoreReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,32 @@ public static IEnumerable<Failure> Deserialize(IFileInfo oldFile, Action<int> lo
if (row.ProblemValue.Substring(part.Offset, part.Word.Length) == part.Word)
continue;
// Test if the ProblemValue has been HTML escaped
var encodedPartWord = WebUtility.HtmlEncode(part.Word);
if (row.ProblemValue.Substring(part.Offset, encodedPartWord.Length) == encodedPartWord)
try
{
if (row.ProblemValue.Substring(part.Offset, encodedPartWord.Length) == encodedPartWord)
{
part.Word = encodedPartWord;
continue;
}
}
catch (ArgumentOutOfRangeException)
{ }

Check notice

Code scanning / CodeQL

Poor error handling: empty catch block Note

Poor error handling: empty catch block.
// Test if the ProblemValue has had a space inserted after a unicode point
var idx = row.ProblemValue.IndexOf(" ");
if (idx > -1 && row.ProblemValue.Substring(part.Offset, part.Word.Length + 1).Remove(idx - 1, 1) == part.Word)
{
part.Word = encodedPartWord;
part.Word = part.Word.Insert(idx - 1, " ");
if (row.ProblemValue.Substring(part.Offset, part.Word.Length) != part.Word)
throw new Exception($"Could not fix additional whitespace in Failure\n{row}");
continue;
}
// Finally, try shifting the offset around to find the word
try
{
FixupOffsets(row, part);
Expand Down

0 comments on commit 7cc0145

Please sign in to comment.