]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
python: Need to utf-8 decode our strings.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Sun, 23 Sep 2018 13:59:39 +0000 (14:59 +0100)
committerperexg <perex@perex.cz>
Wed, 26 Sep 2018 15:31:44 +0000 (17:31 +0200)
lib/py/tvh/htsmsg.py

index 9c925b3cc42f85df0d198bc7f6f5e3fd971ec770..a0001519d0183ab0d34404f6075a32af836b2770 100644 (file)
@@ -174,7 +174,16 @@ def deserialize0(data, typ=HMF_MAP):
         name = data[:nlen]
         data = data[nlen:]
         if typ == HMF_STR:
-            item = data[:dlen]
+            # All of our strings _should_ be utf-8
+            # so need to decode them, otherwise
+            # everything looks fine until you
+            # substr the string elsewhere and
+            # get truncated characters and len is
+            # wrong.
+            try:
+                item = data[:dlen].decode('utf-8')
+            except:
+                item = data[:dlen]
         elif typ == HMF_BIN:
             item = HMFBin(data[:dlen])
         elif typ == HMF_S64: