Commits

David Cramer committed 6180cb2

Only auto link relative urls that start with www.

Comments (0)

Files changed (1)

bbcode/bbtags/web.py

     
     
 class AutoDetectURL(SelfClosingTagNode):
+    # XXX: might be better to enumerate words rather than use regexp?
     open_pattern = re.compile(r'(?P<before>[^[\]])(?P<url>(?P<protocol>(?:ht|f)tp(?:s?)\:\/\/|~/|/'
                               ')?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomain'
                               's)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org'
         match = self.match.groupdict()
         match['label'] = match['url']
         if not match.get('protocol'):
+            # if its not www we dont link it
+            if not match['url'].lower().startswith('www.'):
+                return '%(before)s%(label)s%(after)s' % match
             match['url'] = 'http://' + match['url']
         return '%(before)s<a href="%(url)s">%(label)s</a>%(after)s' % match