#1035358 urlview does not work with URLs containing parentheses

Package:
urlview
Source:
urlview
Description:
Extracts URLs from text
Submitter:
Francesco Ariis
Date:
2023-12-05 02:12:03 UTC
Severity:
normal
#1035358#5
Date:
2023-05-01 19:24:37 UTC
From:
To:
Dear Maintainer,

    urlview does not work with URLs containing parentheses.
To reproduce:

    $ echo "https://en.wikipedia.org/wiki/Close_Combat_(series)" > test.txt
    $ urlview test.txt

You will get a single selection:

    ->    1 https://en.wikipedia.org/wiki/Close_Combat_(series

Notice the missing ‘)’ at the end.

#1035358#10
Date:
2023-05-01 19:45:46 UTC
From:
To:
A workaround is to `cp /etc/urlview/system.urlview ~/.urlview` and
then replace REGEXP with

    REGEXP (((http|https|ftp|gopher)|mailto):(//)?[^ <>"\t]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;\t\n\r<">\):]?[^, <>"\t]*[^ .,;\t\n\r<">:]

(i.e. erasing that last “\)”).

I would send a patch but am not a regexp expert — nor I understood where
upstream repository is —, so I am not 100% sure the modification is sensible.

#1035358#15
Date:
2023-12-05 02:09:42 UTC
From:
To:
This is quite detrimental to the very common case of a URL that's
entirely parenthesised, or one that ends a parenthetical; compare:
  $ tail -n3 text
  Debian#1035358: https://en.wikipedia.org/wiki/Close_Combat_(series)
              vs (https://en.wikipedia.org/wiki/Debian)
              vs  https://en.wikipedia.org/wiki/(You_Gotta)_Fight_for_Your_Right_(To_Party!)
  $ grep -Eio '((http|https|ftp|gopher|gemini|mailto):(//)?[^ <>"]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;<">\):]?[^, <>"]*[^ .,;<">:\)]' text | tail -n3
https://en.wikipedia.org/wiki/Close_Combat_(series
https://en.wikipedia.org/wiki/Debian
https://en.wikipedia.org/wiki/(You_Gotta)_Fight_for_Your_Right_(To_Party!
  $ grep -Eio '((http|https|ftp|gopher|gemini|mailto):(//)?[^ <>"]*|(www|ftp)[0-9]?\.[-a-z0-9.]+)[^ .,;<">\):]?[^, <>"]*[^ .,;<">:]' text | tail -n3
https://en.wikipedia.org/wiki/Close_Combat_(series)
https://en.wikipedia.org/wiki/Debian)
https://en.wikipedia.org/wiki/(You_Gotta)_Fight_for_Your_Right_(To_Party!)
so this trivial solution fixes an IME rare case of an URL ending with a ')'
by breaking the much more common one.

It is quite likely something /can/ be cooked here,
I haven't managed to in a good few minutes of fiddling.

Attaching my test driver.

Best,
наб