From: Eric S. Raymond Date: Thu, 4 Oct 2012 20:10:20 +0000 (-0400) Subject: Improve error diagnostics for malformed JSON. X-Git-Tag: 1.7~11 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=b6681a9d8b02eeed0380c1ea2867d6346950b4d4;p=irker.git Improve error diagnostics for malformed JSON. --- diff --git a/irkerd b/irkerd index 6c8e56c..a9c6eed 100755 --- 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]