handle potentially invalid ascii characters

This commit is contained in:
Jakob Ketterl 2023-09-18 23:39:02 +02:00
parent 4c2f9a67f6
commit f1995d3c6b

View file

@ -699,7 +699,7 @@ class DspManager(SdrSourceEventClient, ClientDemodulatorSecondaryDspEventClient)
b = data.tobytes()
# If we know it's not pickled, let us not unpickle
if len(b) < 2 or b[0] != 0x80 or not 3 <= b[1] <= pickle.HIGHEST_PROTOCOL:
callback(b.decode("ascii"))
callback(b.decode("ascii", errors="replace"))
return
io = BytesIO(b)
@ -709,7 +709,7 @@ class DspManager(SdrSourceEventClient, ClientDemodulatorSecondaryDspEventClient)
except EOFError:
pass
except pickle.UnpicklingError:
callback(b.decode("ascii"))
callback(b.decode("ascii", errors="replace"))
return unpickler