Improve error diagnostics for malformed JSON.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 4 Oct 2012 20:10:20 +0000 (16:10 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 4 Oct 2012 20:10:20 +0000 (16:10 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 6c8e56cb6e2ad70fbcc5a52bd09d19d8d22fa728..a9c6eed7b3b7717b26876370ce5ce738a8dbfdaa 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -399,9 +399,10 @@ class Irker:
             else:
                 channels = request['to']
                 message = request['privmsg']
-                if not isinstance(channels, (list, unicode)) \
-                       and not isinstance(message, unicode):
-                    self.logerr("malformed request - unexpected types: %r" % request)
+                if type(channels) not in (type([]), type(""), type(u"")):
+                    self.logerr("malformed request - unexpected channel type: %r" % channels)
+                if type(message) not in (type(""), type(u"")):
+                    self.logerr("malformed request - unexpected message type: %r" % message)
                 else:
                     if isinstance(channels, unicode):
                         channels = [channels]