Filter: Prevent infinite loop in @binary on characters encoded on more than one byte.

counter ended up to begin negative, and then infinitely decreasing until memoryerror.
This commit is contained in:
Valentin Lorentz 2014-05-08 19:57:35 +00:00
parent 9d084e2e70
commit 0e5694e9c7

View File

@ -146,9 +146,19 @@ class Filter(callbacks.Plugin):
Returns the binary representation of <text>.
"""
L = []
for c in text:
if sys.version_info[0] >= 3:
print(repr(text))
if isinstance(text, str):
bytes_ = text.encode()
else:
bytes_ = text
else:
if isinstance(text, unicode):
text = text.encode()
bytes_ = map(ord, text)
for i in bytes_:
LL = []
i = ord(c)
assert i<=256
counter = 8
while i:
counter -= 1