Mail: Fix infinite loop in FindURL.

Fixes #14746.

Signed-off-by: Augustin Cavalier <[email protected]>
One minor change from owenca's original patch: we can't return
immediately if urlString is NULL, as the caller probably wants
the urlLength.
This commit is contained in:
Owen
2018-12-17 13:45:33 -05:00
committed by Augustin Cavalier
parent d0111efead
commit 1609bb2f67
+10 -7
View File
@@ -314,14 +314,17 @@ FindURL(const BString& string, int32 startIndex, int32& urlPos,
urlLength = strcspn(str, " \t<>)\"\\,\r\n");
// filter out some punctuation marks if they are the last character
char suffix = str[urlLength - 1];
while (suffix == '.'
|| suffix == ','
|| suffix == '?'
|| suffix == '!'
|| suffix == ':'
|| suffix == ';')
while (urlLength > 0) {
char suffix = str[urlLength - 1];
if (suffix != '.'
&& suffix != ','
&& suffix != '?'
&& suffix != '!'
&& suffix != ':'
&& suffix != ';')
break;
urlLength--;
}
if (urlString != NULL)
*urlString = BString(string.String() + urlPos, urlLength);