[gwibber/f14/master] update to 2.31.92

Tom Callaway spot at fedoraproject.org
Fri Sep 3 19:08:56 UTC 2010


commit 37775ce98f5a7dba1b70130f719c7bb0cbc7f368
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Fri Sep 3 15:09:02 2010 -0400

    update to 2.31.92

 gwibber-838bzr-twitter-unicode-hack.patch |   57 +++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/gwibber-838bzr-twitter-unicode-hack.patch b/gwibber-838bzr-twitter-unicode-hack.patch
new file mode 100644
index 0000000..8f0de5f
--- /dev/null
+++ b/gwibber-838bzr-twitter-unicode-hack.patch
@@ -0,0 +1,57 @@
+diff -up gwibber-838bzr/gwibber/microblog/twitter.py.gwibber-unicode-hack gwibber-838bzr/gwibber/microblog/twitter.py
+--- gwibber-838bzr/gwibber/microblog/twitter.py.gwibber-unicode-hack	2010-09-03 11:15:11.000000000 -0400
++++ gwibber-838bzr/gwibber/microblog/twitter.py	2010-09-03 11:17:46.691625005 -0400
+@@ -52,6 +52,44 @@ PROTOCOL_INFO = {
+ URL_PREFIX = "https://twitter.com"
+ API_PREFIX = "https://api.twitter.com/1"
+ 
++import htmlentitydefs
++import unicodedata
++
++def htmlStripEscapes(s):
++    """Replace all html entities (escape sequences) in the string s with their
++    ISO Latin-1 (or bytecode) equivalent.  If no such equivalent can be found
++    then the entity is decomposed into its normal form and the constituent
++    latin characters are retained.  Failing that, the entity is deleted."""
++    i=0
++    while True:
++        i = s.find('&',i)
++        j = s.find(';',i)+1
++        identifier = s[i+1:j-1]
++        if not j==0:
++            replacement = ''
++            if identifier in htmlentitydefs.entitydefs:
++                identifier = htmlentitydefs.entitydefs[identifier]
++                if len(identifier)==1:
++                    replacement = identifier
++                else:
++                    identifier = identifier.strip('&;')
++            if (len(identifier)>1) and (identifier[0] == '#'):
++                identifier = identifier[1:]
++                if identifier[0]=='x':
++                    identifier = int('0'+identifier,16)
++                else:
++                    identifier = int(identifier)
++                if identifier<256:
++                    replacement = chr(identifier)
++                elif identifier<=0xFFFF:
++                    replacement = unicodedata.normalize('NFKD',
++                        unichr(identifier)).encode('latin_1','ignore')
++            s = s[:i] + replacement + s[j:]
++            i += len(replacement)
++        else:
++            break
++    return(s)
++
+ def unescape(s):
+   p = htmllib.HTMLParser(None)
+   p.save_bgn()
+@@ -75,7 +113,7 @@ class Client:
+       m["service"] = "twitter"
+       m["account"] = self.account["id"]
+       m["time"] = util.parsetime(data["created_at"])
+-      m["text"] = unescape(data["text"])
++      m["text"] = unescape(htmlStripEscapes(data["text"]))
+       m["to_me"] = ("@%s" % self.account["username"]) in data["text"]
+ 
+       m["html"] = util.linkify(data["text"],


More information about the scm-commits mailing list