From 0a91bc17399ba7d4dbca24b90b1ae70686843939 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 30 Nov 2017 13:04:32 +0000 Subject: [PATCH] B2017-265 When pasting a Hyphen from MSWord in one of the first three characters the code would go into an infinite loop. --- .../VEPROMS.CSLA.Library/Extension/DisplayText.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs index ed05adc8..cd6ba5b9 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DisplayText.cs @@ -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); }