Show
Ignore:
Timestamp:
07/08/08 20:49:51 (5 months ago)
Author:
steve-e
Message:

[Florob] Improved URL matching.

We don't match all valid URIs like blub:blaa but include common used (non)-urls like www.google.de

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/conversation_textview.py

    r9827 r9898  
    908908                        # add with possible animation 
    909909                        self.tv.add_child_at_anchor(img, anchor) 
    910                 #FIXME: one day, somehow sync with regexp in gajim.py 
    911                 elif special_text.startswith('http://') or \ 
    912                         special_text.startswith('www.') or \ 
    913                         special_text.startswith('ftp://') or \ 
    914                         special_text.startswith('ftp.') or \ 
    915                         special_text.startswith('https://') or \ 
    916                         special_text.startswith('gopher://') or \ 
    917                         special_text.startswith('news://') or \ 
    918                         special_text.startswith('ed2k://') or \ 
    919                         special_text.startswith('irc://') or \ 
    920                         special_text.startswith('sip:') or \ 
    921                         special_text.startswith('magnet:'): 
    922                         # it's a url 
     910                elif special_text.startswith('www.') or \ 
     911                special_text.startswith('ftp.'): 
    923912                        tags.append('url') 
    924913                        use_other_tags = False 
     
    992981                        use_other_tags = False 
    993982                else: 
    994                         #it's a url 
    995                         tags.append('url') 
    996                         use_other_tags = False 
     983                        # Check if we accept this as an uri 
     984                        schemes = gajim.config.get('uri_schemes').split() 
     985                        for scheme in schemes: 
     986                                if special_text.startswith(scheme + ':'): 
     987                                        tags.append('url') 
     988                                        use_other_tags = False 
     989                        # It's not a accepted uri 
     990                        if use_other_tags: 
     991                                end_iter = buffer.get_end_iter() 
     992                                buffer.insert_with_tags_by_name(end_iter, special_text, *other_tags) 
    997993 
    998994                if len(tags) > 0: 
     
    11721168                if name and (text.startswith('/me ') or text.startswith('/me\n')): 
    11731169                        text = '* ' + name + text[3:] 
     1170                        text_tags.append('italic') 
    11741171                # detect urls formatting and if the user has it on emoticons 
    11751172                index = self.detect_and_print_special_text(text, text_tags)