Gentoo Archives: gentoo-commits

From: "Justin Lecher (jlec)" <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-im/gajim/files: gajim-0.14.4-debian_patches_unicode.patch
Date: Sat, 29 Oct 2011 19:55:56
Message-Id: 20111029195546.EE93F2004C@flycatcher.gentoo.org
1 jlec 11/10/29 19:55:46
2
3 Added: gajim-0.14.4-debian_patches_unicode.patch
4 Log:
5 Try debian solution for the unicode problem, #383463
6
7 (Portage version: 2.2.0_alpha71/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 net-im/gajim/files/gajim-0.14.4-debian_patches_unicode.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/gajim/files/gajim-0.14.4-debian_patches_unicode.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-im/gajim/files/gajim-0.14.4-debian_patches_unicode.patch?rev=1.1&content-type=text/plain
14
15 Index: gajim-0.14.4-debian_patches_unicode.patch
16 ===================================================================
17 Index: gajim-0.14.4/src/common/connection_handlers.py
18 ===================================================================
19 --- gajim-0.14.4.orig/src/common/connection_handlers.py 2011-05-31 18:00:32.000000000 +0200
20 +++ gajim-0.14.4/src/common/connection_handlers.py 2011-10-23 19:52:10.679106710 +0200
21 @@ -1607,6 +1607,8 @@
22 if keyID:
23 def decrypt_thread(encmsg, keyID):
24 decmsg = self.gpg.decrypt(encmsg, keyID)
25 + decmsg = self.connection.Dispatcher.replace_non_character(
26 + decmsg)
27 # \x00 chars are not allowed in C (so in GTK)
28 msgtxt = helpers.decode_string(decmsg.replace('\x00', ''))
29 encrypted = 'xep27'
30 Index: gajim-0.14.4/src/common/stanza_session.py
31 ===================================================================
32 --- gajim-0.14.4.orig/src/common/stanza_session.py 2011-05-31 18:00:32.000000000 +0200
33 +++ gajim-0.14.4/src/common/stanza_session.py 2011-10-23 20:05:40.979105851 +0200
34 @@ -375,6 +375,12 @@
35 for child in parsed.getChildren():
36 stanza.addChild(node=child)
37
38 + # replace non-character unicode
39 + body = stanza.getBody()
40 + if body:
41 + stanza.setBody(
42 + self.conn.connection.Dispatcher.replace_non_character(body))
43 +
44 return stanza
45
46 def decrypt(self, ciphertext):
47 Index: gajim-0.14.4/src/common/xmpp/dispatcher_nb.py
48 ===================================================================
49 --- gajim-0.14.4.orig/src/common/xmpp/dispatcher_nb.py 2011-05-22 13:12:53.000000000 +0200
50 +++ gajim-0.14.4/src/common/xmpp/dispatcher_nb.py 2011-10-23 19:52:10.709106647 +0200
51 @@ -20,7 +20,7 @@
52 different handlers to different XMPP stanzas and namespaces
53 """
54
55 -import simplexml, sys, locale
56 +import re, simplexml, sys, locale
57 from xml.parsers.expat import ExpatError
58 from plugin import PlugIn
59 from protocol import (NS_STREAMS, NS_XMPP_STREAMS, NS_HTTP_BIND, Iq, Presence,
60 @@ -89,6 +89,24 @@
61 self.UnregisterHandler, self.RegisterProtocol,
62 self.SendAndWaitForResponse, self.SendAndCallForResponse,
63 self.getAnID, self.Event, self.send]
64 +
65 + # \ufddo -> \ufdef range
66 + c = u'\ufdd0'
67 + r = c.encode('utf8')
68 + while (c < u'\ufdef'):
69 + c = unichr(ord(c) + 1)
70 + r += '|' + c.encode('utf8')
71 +
72 + # \ufffe-\uffff, \u1fffe-\u1ffff, ..., \u10fffe-\u10ffff
73 + c = u'\ufffe'
74 + r += '|' + c.encode('utf8')
75 + r += '|' + unichr(ord(c) + 1).encode('utf8')
76 + while (c < u'\U0010fffe'):
77 + c = unichr(ord(c) + 0x10000)
78 + r += '|' + c.encode('utf8')
79 + r += '|' + unichr(ord(c) + 1).encode('utf8')
80 +
81 + self.invalid_chars_re = re.compile(r)
82
83 def getAnID(self):
84 global outgoingID
85 @@ -174,6 +192,9 @@
86 raise ValueError('Incorrect stream start: (%s,%s). Terminating.'
87 % (tag, ns))
88
89 + def replace_non_character(self, data):
90 + return re.sub(self.invalid_chars_re, u'\ufffd'.encode('utf-8'), data)
91 +
92 def ProcessNonBlocking(self, data):
93 """
94 Check incoming stream for data waiting
95 @@ -189,6 +210,7 @@
96 # disconnect method will never be called.
97 # Is this intended?
98 # also look at transports start_disconnect()
99 + data = self.replace_non_character(data)
100 for handler in self._cycleHandlers:
101 handler(self)
102 if len(self._pendingExceptions) > 0: