Merge lp:~roignac/gwibber/Bug324809 into lp:gwibber

Proposed by Vadim Rutkovsky
Status: Merged
Merged at revision: 935
Proposed branch: lp:~roignac/gwibber/Bug324809
Merge into: lp:gwibber
Diff against target: 25 lines (+5/-3)
1 file modified
gwibber/microblog/util/__init__.py (+5/-3)
To merge this branch: bzr merge lp:~roignac/gwibber/Bug324809
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Omer Akram (community) Approve
Review via email: mp+33992@code.launchpad.net

Description of the change

Fixes lp:324809 - urls like www.google.com are recognized correctly, http:// is added to the href

To post a comment you must log in.
Revision history for this message
Omer Akram (om26er) wrote :

works

review: Approve
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/microblog/util/__init__.py'
2--- gwibber/microblog/util/__init__.py 2010-08-22 18:30:36 +0000
3+++ gwibber/microblog/util/__init__.py 2010-08-28 12:33:42 +0000
4@@ -17,8 +17,8 @@
5 URL_SCHEMES = ('http', 'https', 'ftp', 'mailto', 'news', 'gopher',
6 'nntp', 'telnet', 'wais', 'prospero', 'aim', 'webcal')
7
8-URL_FORMAT = (r'(?<!\w)((?:%s):' # protocol + :
9- '/*(?!/)(?:' # get any starting /'s
10+URL_FORMAT = (r'(?<!\w)(((?:%s)://|(?:www\.))' # protocol + :// or www.
11+ '(?!/)(?:' # get any starting /'s
12 '[\w$\+\*@&=\-/]' # reserved | unreserved
13 '|%%[a-fA-F0-9]{2}' # escape
14 '|[\?\.:\(\),;!\'\~](?!(?:\s|$))' # punctuation
15@@ -37,7 +37,9 @@
16 def linkify(text, subs=[], escape=True):
17 if escape: text = cgi.escape(text)
18 for f, r in subs: text = f.sub(r, text)
19- return PARSE_LINK.sub('<a href="\\1">\\1</a>', text)
20+ link = PARSE_LINK.sub('<a href="\\1">\\1</a>', text)
21+ # if link has www only, add http:// to the href
22+ return re.compile(r'"www.', re.U).sub('"http://www.', link)
23
24 def imgpreview(text):
25 thumbre = {