Changeset 747

Show
Ignore:
Timestamp:
03/24/10 15:51:46 (23 months ago)
Author:
confluence
Message:

escape @s in urls to avoid horrible collision with twitter usernames

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • confluence/feedfilters/twitterfilter.py

    r635 r747  
    2222statusidpattern = re.compile(r"http://twitter.com/.*/statuses/([0-9]*)") 
    2323 
     24def url_replace(mobj): 
     25    url = mobj.group(1).replace("@", "%40") 
     26    return r"<a href='%s'>%s</a>" % (url, url) 
     27 
    2428xml = xml.dom.minidom.parseString(sys.stdin.read()) 
    2529 
     
    4145    statusid = statusidpattern.match(guid.data).group(1) 
    4246 
    43     text = linkurls.sub(r"<a href='\1'>\1</a>", text) 
     47    text = linkurls.sub(url_replace, text) 
    4448    text = linknames.sub(r"<a href='http://twitter.com/\1'>@\1</a>", text) 
    4549    text = hashtags.sub(r"\1<a href='http://search.twitter.com/search?q=%23\1'>#\2</a>", text)