Skip to content

Commit

Permalink
html.py: hone regexes for URL linking
Browse files Browse the repository at this point in the history
First, a couple of extraneous quotes were left in the second regex around
"</a>".

Second, it is possible that a period or question mark could be used to end
a sentence, rather than be part of the URL. So check that these characters
are followed by an alphanumeric character to make them part of the URL.
  • Loading branch information
groggyd88 committed May 16, 2014
1 parent da388ce commit e3adf00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions data/tools/addon_manager/html.py
Expand Up @@ -137,8 +137,8 @@ def w(x):
) % (icon, imgurl))
described = v("description", "(no description)")
if described != "(no description)":
described = re.sub(r'(?<![">])http://[\w./?&=%~-]+', r'<a href="\g<0>">\g<0></a>', described)
described = re.sub(r'(?<![\w>"/])(forums?|r|R|wiki)\.wesnoth\.org[\w./?&=%~-]+', r'<a href="http://\g<0>">\g<0>"</a>"', described)
described = re.sub(r'(?<![">])http://([\w/=%~-]|[.?&]\w)+', r'<a href="\g<0>">\g<0></a>', described)
described = re.sub(r'(?<![\w>"/])(forums?|r|R|wiki)\.wesnoth\.org([\w/=%~-]|[.?&]\w)*', r'<a href="http://\g<0>">\g<0></a>', described)
w('<div class="desc"><b>%s</b><pre>%s</pre></div></td>' % (
name, described))
w("<td><b>%s</b><br/>" % name)
Expand Down

0 comments on commit e3adf00

Please sign in to comment.