From f9d0421d332c653c94cac52c8734d7a6e1fc1802 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 10 Mar 2006 18:48:14 +0000 Subject: [PATCH] jids and nicks are now punycoded before we store on HD. See #1030 --- src/common/connection.py | 13 +++++++++---- src/gtkgui_helpers.py | 7 +++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index e2edcead9..962b01d40 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -45,6 +45,7 @@ if os.name != 'nt': signal.signal(signal.SIGPIPE, signal.SIG_DFL) from calendar import timegm +from encodings.punycode import punycode_encode import common.xmpp @@ -272,7 +273,8 @@ class Connection: def save_vcard_to_hd(self, full_jid, card): jid, nick = gajim.get_room_and_nick_from_fjid(full_jid) - path = os.path.join(gajim.VCARD_PATH, jid) + puny_jid = punycode_encode(jid) + path = os.path.join(gajim.VCARD_PATH, puny_jid) if jid in self.room_jids: # remove room_jid file if needed if os.path.isfile(path): @@ -280,7 +282,8 @@ class Connection: # create folder if needed if not os.path.isdir(path): os.mkdir(path, 0700) - path_to_file = os.path.join(gajim.VCARD_PATH, jid, nick) + puny_nick = punycode_encode(nick) + path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) else: path_to_file = path fil = open(path_to_file, 'w') @@ -2356,10 +2359,12 @@ class Connection: return {} if vcard was too old return None if we don't have cached vcard''' jid, nick = gajim.get_room_and_nick_from_fjid(fjid) + puny_jid = punycode_encode(jid) if is_fake_jid: - path_to_file = os.path.join(gajim.VCARD_PATH, jid, nick) + puny_nick = punycode_encode(nick) + path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) else: - path_to_file = os.path.join(gajim.VCARD_PATH, jid) + path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid) if not os.path.isfile(path_to_file): return None # We have the vcard cached diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 31bfe1b74..bc840b641 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -23,6 +23,7 @@ import gobject import pango import os import sys +from encodings.punycode import punycode_encode import vcard @@ -443,10 +444,12 @@ def get_avatar_pixbuf_from_cache(fjid, is_fake_jid = False): # don't show avatar for the transport itself return None + puny_jid = punycode_encode(jid) if is_fake_jid: - path = os.path.join(gajim.VCARD_PATH, jid, nick) + puny_nick = punycode_encode(nick) + path = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick) else: - path = os.path.join(gajim.VCARD_PATH, jid) + path = os.path.join(gajim.VCARD_PATH, puny_jid) if not os.path.isfile(path): return 'ask'