Skip to content

Commit

Permalink
Fix missing length check for author last-char-is-junk check
Browse files Browse the repository at this point in the history
  • Loading branch information
FenPhoenix committed Jul 8, 2024
1 parent 3516ea1 commit eae5457
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions FMScanner/Core/Scanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4706,21 +4706,19 @@ private string CleanupCopyrightAuthor(string author)
Match yearMatch = CopyrightAuthorYearRegex.Match(author);
if (yearMatch.Success) author = author.Substring(0, yearMatch.Index);

const string junkChars = "!@#$%^&*";
bool authorLastCharIsJunk = false;
char lastChar = author[^1];
for (int i = 0; i < junkChars.Length; i++)
if (author.Length >= 2 && author[^2] == ' ')
{
if (lastChar == junkChars[i])
const string junkChars = "!@#$%^&*";
char lastChar = author[^1];
for (int i = 0; i < junkChars.Length; i++)
{
authorLastCharIsJunk = true;
break;
if (lastChar == junkChars[i])
{
author = author.Substring(0, author.Length - 2);
break;
}
}
}
if (authorLastCharIsJunk && author[^2] == ' ')
{
author = author.Substring(0, author.Length - 2);
}

return author.TrimEnd(CA_Period).Trim();
}
Expand Down

0 comments on commit eae5457

Please sign in to comment.