Fix URL matching regex

The URL matching regex as currently used by dust is too liberal, and will just
match about anything.

Some examples:

  "establishing connection..." => connection...
  "setting volume to [50%]" => 50%]

The following expression is an adapted copy of urxvt's URL matcher.
This commit is contained in:
Yuri D'Elia 2014-03-06 18:05:22 +01:00
parent 2638178e5a
commit 2023623b16

4
menu.c
View File

@ -28,7 +28,9 @@ char *extract_urls(const char *to_match)
if (!is_initialized) {
char *regex =
"((http[s]?|ftp[s]?)(://))?(www\\.)?[[:alnum:]._-]+\\.[^[:space:].\"<>]{2,}";
"\\b(https?://|ftps?://|news://|mailto:|file://|www\\.)"
"[[:alnum:]\\-\\@;/?:&=%$.+!*\x27,~#]*"
"(\\([[:alnum:]\\-\\@;/?:&=%$.+!*\x27,~#]*\\)|[[:alnum:]\\-\\@;/?:&=%$+*~])+";
int ret = regcomp(&cregex, regex, REG_EXTENDED | REG_ICASE);
if (ret != 0) {
printf("failed to compile regex\n");