Ignore invalid UTF-8 data.

This commit is contained in:
Florian Bruhin 2014-10-13 21:17:49 +02:00
parent 7d492d7556
commit 879cdf8904

View File

@ -97,14 +97,16 @@ class IPCServer(QObject):
"""Read json data from the client.""" """Read json data from the client."""
while self._socket.canReadLine(): while self._socket.canReadLine():
data = bytes(self._socket.readLine()) data = bytes(self._socket.readLine())
decoded = data.decode('utf-8') try:
decoded = data.decode('utf-8')
except UnicodeDecodeError:
return
try: try:
args = json.loads(decoded) args = json.loads(decoded)
except ValueError: except ValueError:
return return
else: app = objreg.get('app')
app = objreg.get('app') app.process_args(args)
app.process_args(args)
def shutdown(self): def shutdown(self):
"""Shut down the IPC server cleanly.""" """Shut down the IPC server cleanly."""