]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Decode the funky chars coming from Xonotic.
authorAnt Zucaro <azucaro@gmail.com>
Mon, 21 Nov 2011 17:41:49 +0000 (12:41 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Mon, 21 Nov 2011 17:41:49 +0000 (12:41 -0500)
xonstat/util.py
xonstat/views/submission.py

index b0b548100ad26cd8ede9b82e2f85b4efc3161c66..9caf856476b688cd88a84b8be05a08e8f4b664b8 100755 (executable)
@@ -43,6 +43,9 @@ def qfont_decode(qstr=''):
     """
     Convert the qfont characters in a string to ascii.
     """
+    if qstr is None:
+        qstr = ''
+
     chars = []
     for c in qstr:
         if c >= u'\ue000' and c <= u'\ue0ff':
index 6f776a2466db97f4666e5779926837f65052af8d..0d5acf2befd794103f093a6d1ee9b879cb8e00fa 100755 (executable)
@@ -8,7 +8,7 @@ from sqlalchemy import Sequence
 from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\r
 from xonstat.d0_blind_id import d0_blind_id_verify\r
 from xonstat.models import *\r
-from xonstat.util import strip_colors\r
+from xonstat.util import strip_colors, qfont_decode\r
 \r
 log = logging.getLogger(__name__)\r
 \r
@@ -420,9 +420,9 @@ def parse_body(request):
             (key, value) = line.strip().split(' ', 1)\r
 \r
             # Server (S) and Nick (n) fields can have international characters.\r
-            # We encode these as UTF-8.\r
+            # We first convert to normal ASCII, then encode them as UTF-8.\r
             if key in 'S' 'n':\r
-                value = unicode(value, 'utf-8')\r
+                value = qfont_decode(unicode(value, 'utf-8'))\r
     \r
             if key in 'V' 'T' 'G' 'M' 'S' 'C' 'R' 'W':\r
                 game_meta[key] = value\r