* Slightly improved invalid suffix removal from URLs.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25872 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-06-09 13:01:58 +00:00
parent 258fd455bc
commit a7b8e0f267
+12 -15
View File
@@ -346,10 +346,19 @@ CheckForURL(const char *string, size_t &urlLength, BString *url = NULL)
if (type == 0)
return 0;
int32 index = 0;
if (type == TYPE_URL) {
index = strcspn(string, " <>\"\r\n");
int32 index = strcspn(string, " \t<>)\"\\,\r\n");
// filter out some punctuation marks if they are the last character
char suffix = string[index - 1];
if (suffix == '.'
|| suffix == ','
|| suffix == '?'
|| suffix == '!'
|| suffix == ':'
|| suffix == ';')
index--;
if (type == TYPE_URL) {
char *parenthesis = NULL;
// filter out a trailing ')' if there is no left parenthesis before
@@ -366,18 +375,6 @@ CheckForURL(const char *string, size_t &urlLength, BString *url = NULL)
index--;
}
}
else
index = strcspn(string, " \t>)\"\\,\r\n");
// filter out some punctuation marks if they are the last character
char suffix = string[index - 1];
if (suffix == '.'
|| suffix == ','
|| suffix == '?'
|| suffix == '!'
|| suffix == ':'
|| suffix == ';')
index--;
if (url != NULL) {
// copy the address to the specified string