diff --git a/src/apps/mail/Content.cpp b/src/apps/mail/Content.cpp index 6775b6c527..017c9cab3c 100644 --- a/src/apps/mail/Content.cpp +++ b/src/apps/mail/Content.cpp @@ -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);