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,9 +820,9 @@ namespace VEPROMS.CSLA.Library
int indx = rtbString.IndexOf('-'); int indx = rtbString.IndexOf('-');
while (indx > -1) 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 (rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\') if (indx < 2 || rtbString[indx - 1] != 'i' || rtbString[indx - 2] != 'f' || rtbString[indx - 3] != '\\')
{ {
rtbString = rtbString.Remove(indx, 1); rtbString = rtbString.Remove(indx, 1);
rtbString = rtbString.Insert(indx, @"\u8209?"); rtbString = rtbString.Insert(indx, @"\u8209?");
@ -830,7 +830,6 @@ namespace VEPROMS.CSLA.Library
if (indx + 1 > rtbString.Length) indx = -1; if (indx + 1 > rtbString.Length) indx = -1;
else indx = rtbString.IndexOf('-', indx + 1); else indx = rtbString.IndexOf('-', indx + 1);
} }
}
return Save(rtbString); return Save(rtbString);
} }
public bool Save(string modtext) public bool Save(string modtext)