File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5463,24 +5463,24 @@ bool VwTextSelection::ReplacementTextIsSingleParagraph(ITsString* replacementTst
54635463 int replacementCharCount;
54645464 SmartBstr replacementBstr;
54655465 CheckHr (replacementTstr->get_Length (&replacementCharCount));
5466+ if (replacementCharCount <= 0 )
5467+ return false ;
5468+
54665469 CheckHr (replacementTstr->get_Text (&replacementBstr));
54675470 const wchar* replacementText = replacementBstr.Chars ();
5468- for (int ii = 0 ; ii < replacementCharCount; ii++)
5471+
5472+ // A single paragraph must end with exactly one trailing '\n'.
5473+ if (replacementText[replacementCharCount - 1 ] != ' \n ' )
5474+ return false ;
5475+
5476+ // Ensure there are no other '\n' characters before the final one.
5477+ for (int ii = 0 ; ii < replacementCharCount - 1 ; ii++)
54695478 {
54705479 if (replacementText[ii] == ' \n ' )
5471- {
5472- // The last character is a '\n' and there are no other '\n' characters in the string.
5473- if (ii == replacementCharCount - 1 )
5474- {
5475- return true ;
5476- }
5477- else
5478- {
5479- break ;
5480- }
5481- }
5480+ return false ;
54825481 }
5483- return false ;
5482+
5483+ return true ;
54845484}
54855485
54865486/* ----------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments