mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
ircutils.FormatParser: Make getInt only get integers that are valid colors
If a colored message were wrapped just right (e.g., a colored number ending the chunk), FormatParser would gobble up the color format code and the number in the message, causing a KeyError when trying to look up the color in mircColors. Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
parent
786d184b0a
commit
a42ab2e2d4
@ -357,7 +357,8 @@ class Filter(callbacks.Plugin):
|
|||||||
if c == ' ':
|
if c == ' ':
|
||||||
return c
|
return c
|
||||||
if fg is None:
|
if fg is None:
|
||||||
fg = str(random.randint(2, 15)).zfill(2)
|
fg = random.randint(2, 15)
|
||||||
|
fg = str(fg).zfill(2)
|
||||||
return '\x03%s%s' % (fg, c)
|
return '\x03%s%s' % (fg, c)
|
||||||
|
|
||||||
def colorize(self, irc, msg, args, text):
|
def colorize(self, irc, msg, args, text):
|
||||||
|
@ -410,11 +410,16 @@ class FormatParser(object):
|
|||||||
i = 0
|
i = 0
|
||||||
setI = False
|
setI = False
|
||||||
c = self.getChar()
|
c = self.getChar()
|
||||||
while c.isdigit() and i < 100:
|
while c.isdigit():
|
||||||
setI = True
|
j = i * 10
|
||||||
i *= 10
|
j += int(c)
|
||||||
i += int(c)
|
if j >= 16:
|
||||||
c = self.getChar()
|
self.ungetChar(c)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
setI = True
|
||||||
|
i = j
|
||||||
|
c = self.getChar()
|
||||||
self.ungetChar(c)
|
self.ungetChar(c)
|
||||||
if setI:
|
if setI:
|
||||||
return i
|
return i
|
||||||
@ -426,6 +431,8 @@ class FormatParser(object):
|
|||||||
c = self.getChar()
|
c = self.getChar()
|
||||||
if c == ',':
|
if c == ',':
|
||||||
context.bg = self.getInt()
|
context.bg = self.getInt()
|
||||||
|
else:
|
||||||
|
self.ungetChar(c)
|
||||||
|
|
||||||
def wrap(s, length):
|
def wrap(s, length):
|
||||||
processed = []
|
processed = []
|
||||||
|
Loading…
Reference in New Issue
Block a user