* 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:
+12
-15
@@ -346,10 +346,19 @@ CheckForURL(const char *string, size_t &urlLength, BString *url = NULL)
|
|||||||
if (type == 0)
|
if (type == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int32 index = 0;
|
int32 index = strcspn(string, " \t<>)\"\\,\r\n");
|
||||||
if (type == TYPE_URL) {
|
|
||||||
index = strcspn(string, " <>\"\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;
|
char *parenthesis = NULL;
|
||||||
|
|
||||||
// filter out a trailing ')' if there is no left parenthesis before
|
// 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--;
|
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) {
|
if (url != NULL) {
|
||||||
// copy the address to the specified string
|
// copy the address to the specified string
|
||||||
|
|||||||
Reference in New Issue
Block a user