diff roundup/cgi/templating.py @ 4009:e335ce40d6c8

Make URL matching code less matchy
author Richard Jones <richard@users.sourceforge.net>
date Mon, 01 Sep 2008 01:37:00 +0000
parents 13161539e5bd
children 797eacd945af
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Mon Sep 01 00:43:02 2008 +0000
+++ b/roundup/cgi/templating.py	Mon Sep 01 01:37:00 2008 +0000
@@ -1247,11 +1247,18 @@
 class StringHTMLProperty(HTMLProperty):
     hyper_re = re.compile(r'''(
         (?P<url>
-          ((ht|f)tp(s?)://|www\.)?          # prefix
+         (
+          (ht|f)tp(s?)://                   # protocol
           ([\w]+:\w+@)?                     # username/password
-          (([\w\-]+\.)+([\w]{2,5}))         # hostname
-          (:[\d]{1,5})?                     # port
-          (/[\w\-$.+!*(),;:@&=?/~\\#%]*)?   # path etc.
+          ([\w\-]+\.)+                      # hostname
+          [\w]{2,5}                         # TLD
+         |                                  # ... or ...
+          www\.                             # "www."
+          ([\w\-]+\.)+                      # hostname
+          [\w]{2,5}                         # TLD
+         )
+         (:[\d]{1,5})?                     # port
+         (/[\w\-$.+!*(),;:@&=?/~\\#%]*)?   # path etc.
         )|
         (?P<email>[-+=%/\w\.]+@[\w\.\-]+)|
         (?P<item>(?P<class>[A-Za-z_]+)(\s*)(?P<id>\d+))

Roundup Issue Tracker: http://roundup-tracker.org/