URL_REGEXP and URLs ending with ')'

Dennis Preiser <[email protected]> Fri, 18 Apr 2014 17:31:19 +0200
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

Wikipedia use many URLs that end with ')', e.g.

	<http://en.wikipedia.org/wiki/Tin_(newsreader)>

Tin's regex does not recognize the ')' as part of the URL. The attached
patch fixes this for me but I'm not sure if this is the right solution.

In the diff it's hard to see what I've changed. It is this round bracket
at the end of the regex, which I have removed:

... (?:/[^)\\]\\>\"\\s]*|$|(?=[)\\]\\>\"\\s]))"
          ^

Dennis

--2oS5YaxWCcQjTEyO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="url_regex.diff"

diff -urp tin-2.2.1_r2/include/tin.h tin-2.2.1_r3/include/tin.h
--- tin-2.2.1_r2/include/tin.h	2014-01-17 08:26:48.000000000 +0100
+++ tin-2.2.1_r3/include/tin.h	2014-04-18 15:53:31.000000000 +0200
@@ -701,7 +701,7 @@ enum rc_state { RC_IGNORE, RC_CHECK, RC_
 #	if 0 /* this one is ok for IPv4 */
 #		define URL_REGEX	"\\b(?:https?|ftp|gopher)://(?:[^:@/\\s]*(?::[^:@/\\s]*)?@)?(?:(?:(?:[^\\W_](?:(?:-(?!-)|[^\\W_]){0,61}[^\\W_])?|xn--[^\\W_](?:-(?!-)|[^\\W_]){1,57}[^\\W_])\\.)+[a-z]{2,6}\\.?|localhost|(?:(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))(?::\\d+)?(?:/[^)\\]\\>\"\\s]*|$|(?=[)\\]\\>\"\\s]))"
 #	else	/* this one should be IPv6 safe - test me! */
-#		define URL_REGEX	"\\b(?:https?|ftp|gopher)://(?:[^:@/\\s]*(?::[^:@/\\s]*)?@)?(?:(?:(?:[^\\W_](?:(?:-|[^\\W_]){0,61}(?<!---)[^\\W_])?|xn--[^\\W_](?:-(?!-)|[^\\W_]){1,57}[^\\W_])\\.)+[a-z]{2,6}\\.?|localhost|(?:(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)|\\[(?:(?:[0-9A-F]{0,4}:){1,7}[0-9A-F]{1,4}|(?:[0-9A-F]{0,4}:){1,3}(?:(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))\\])(?::\\d+)?(?:/[^)\\]\\>\"\\s]*|$|(?=[)\\]\\>\"\\s]))"
+#		define URL_REGEX	"\\b(?:https?|ftp|gopher)://(?:[^:@/\\s]*(?::[^:@/\\s]*)?@)?(?:(?:(?:[^\\W_](?:(?:-|[^\\W_]){0,61}(?<!---)[^\\W_])?|xn--[^\\W_](?:-(?!-)|[^\\W_]){1,57}[^\\W_])\\.)+[a-z]{2,6}\\.?|localhost|(?:(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)|\\[(?:(?:[0-9A-F]{0,4}:){1,7}[0-9A-F]{1,4}|(?:[0-9A-F]{0,4}:){1,3}(?:(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(?:2[0-4]\\d|25[0-5]|[01]?\\d\\d?))\\])(?::\\d+)?(?:/[^\\]\\>\"\\s]*|$|(?=[)\\]\\>\"\\s]))"
 #	endif /* 0 */
 #endif /* 0 */
 /*

--2oS5YaxWCcQjTEyO--