=== modified file 'applets/maintained/feeds/classes.py' --- applets/maintained/feeds/classes.py 2010-06-29 21:16:37 +0000 +++ applets/maintained/feeds/classes.py 2010-08-25 19:38:07 +0000 @@ -982,24 +982,26 @@ widget.set_markup(widget.get_text()) def safify(text): - text = text.replace('<', '<').replace('>', '>').replace('"', '"') - text2 = list(text) - for char, i in enumerate(text2): - if char == '&': - ok = False - if len(text2) >= i: - if text2[i + 1] == '#' and (text2[i + 4] == ';' or text2[i + 6] == ';'): - ok = True - elif len(text2) - 1 >= i + 3: - if text2[i + 1:3] == 'lt;': - ok = True - elif text2[i + 1:3] == 'gt;': - ok = True - elif len(text2) -1 >= i + 4: - if text2[i + 1:4] == 'quot;': - ok = True - - if not ok: - text2[i] = '&' - - return ''.join(text2) + """Removes HTML/XML character references and entities from a text string. + Taken from Fredrik Lundh - http://effbot.org/zone/re-sub.htm#unescape-html + + """ + def fixup(m): + text = m.group(0) + if text[:2] == "&#": + # character reference + try: + if text[:3] == "&#x": + return unichr(int(text[3:-1], 16)) + else: + return unichr(int(text[2:-1])) + except ValueError: + pass + else: + # named entity + try: + text = unichr(htmlentitydefs.name2codepoint[text[1:-1]]) + except KeyError: + pass + return text # leave as is + return re.sub("&#?\w+;", fixup, text) === modified file 'applets/maintained/feeds/feeds.py' --- applets/maintained/feeds/feeds.py 2010-06-29 21:16:37 +0000 +++ applets/maintained/feeds/feeds.py 2010-08-25 19:28:39 +0000 @@ -379,7 +379,7 @@ button.child.set_use_underline(False) button.set_relief(gtk.RELIEF_NONE) if len(entry['title']) > 25: - button.set_tooltip_text(entry['title']) + button.set_tooltip_text(classes.safify(entry['title'])) button.connect('clicked', self.feed_item_clicked, (feed, i)) button.show_all()