B2017-265 When pasting a Hyphen from MSWord in one of the first three characters the code would go into an infinite loop.

This commit is contained in:
Rich 2017-11-30 13:04:32 +00:00
parent 92eb33c044
commit 0a91bc1739

View File

@ -820,16 +820,15 @@ namespace VEPROMS.CSLA.Library
int indx = rtbString.IndexOf('-');
while (indx > -1)
{
if (indx > 2)
// B2017-265 - Make sure that the location is at least 2 if checking the previous three charracters.
// This occurs when pasting from MSWord
if (indx < 2 || rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\')
{
if (rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\')
{
rtbString = rtbString.Remove(indx, 1);
rtbString = rtbString.Insert(indx, @"\u8209?");
}
if (indx + 1 > rtbString.Length) indx = -1;
else indx = rtbString.IndexOf('-', indx+1);
rtbString = rtbString.Remove(indx, 1);
rtbString = rtbString.Insert(indx, @"\u8209?");
}
if (indx + 1 > rtbString.Length) indx = -1;
else indx = rtbString.IndexOf('-', indx + 1);
}
return Save(rtbString);
}