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:
@@ -314,14 +314,17 @@ FindURL(const BString& string, int32 startIndex, int32& urlPos,
|
|||||||
urlLength = strcspn(str, " \t<>)\"\\,\r\n");
|
urlLength = strcspn(str, " \t<>)\"\\,\r\n");
|
||||||
|
|
||||||
// filter out some punctuation marks if they are the last character
|
// filter out some punctuation marks if they are the last character
|
||||||
char suffix = str[urlLength - 1];
|
while (urlLength > 0) {
|
||||||
while (suffix == '.'
|
char suffix = str[urlLength - 1];
|
||||||
|| suffix == ','
|
if (suffix != '.'
|
||||||
|| suffix == '?'
|
&& suffix != ','
|
||||||
|| suffix == '!'
|
&& suffix != '?'
|
||||||
|| suffix == ':'
|
&& suffix != '!'
|
||||||
|| suffix == ';')
|
&& suffix != ':'
|
||||||
|
&& suffix != ';')
|
||||||
|
break;
|
||||||
urlLength--;
|
urlLength--;
|
||||||
|
}
|
||||||
|
|
||||||
if (urlString != NULL)
|
if (urlString != NULL)
|
||||||
*urlString = BString(string.String() + urlPos, urlLength);
|
*urlString = BString(string.String() + urlPos, urlLength);
|
||||||
|
|||||||
Reference in New Issue
Block a user