mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 01:24:05 +01:00
String: Give a more useful message when decoding base64 fails
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
parent
dfbec681d1
commit
ebfe8e66f3
@ -1,6 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2003-2005, Jeremiah Fincher
|
||||
# Copyright (c) 2008, James Vega
|
||||
# Copyright (c) 2008-2009, James Vega
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -29,6 +29,7 @@
|
||||
###
|
||||
|
||||
import types
|
||||
import binascii
|
||||
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
@ -81,6 +82,10 @@ class String(callbacks.Plugin):
|
||||
irc.reply(text.decode(encoding).encode('utf-8'))
|
||||
except LookupError:
|
||||
irc.errorInvalid('encoding', encoding)
|
||||
except binascii.Error:
|
||||
irc.errorInvalid('base64 string',
|
||||
s='Base64 strings must be a multiple of 4 in '
|
||||
'length, padded with \'=\' if necessary.')
|
||||
decode = wrap(decode, ['something', 'text'])
|
||||
|
||||
def levenshtein(self, irc, msg, args, s1, s2):
|
||||
|
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2003-2005, Jeremiah Fincher
|
||||
# Copyright (c) 2009, James Vega
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -104,6 +105,7 @@ class StringTestCase(PluginTestCase):
|
||||
self.assertNotRegexp('encode aldkfja foobar', 'LookupError')
|
||||
self.assertNotRegexp('decode asdflkj foobar', 'LookupError')
|
||||
self.assertResponse('decode zlib [encode zlib %s]' % s, s)
|
||||
self.assertRegexp('decode base64 $BCfBg7;9D;R(B', 'padded with')
|
||||
|
||||
def testRe(self):
|
||||
self.assertResponse('re "m/system time/" [status cpu]', 'system time')
|
||||
|
Loading…
Reference in New Issue
Block a user