mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-10-10 13:57:25 +02:00
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:
parent
9d084e2e70
commit
0e5694e9c7
@ -146,9 +146,19 @@ class Filter(callbacks.Plugin):
|
|||||||
Returns the binary representation of <text>.
|
Returns the binary representation of <text>.
|
||||||
"""
|
"""
|
||||||
L = []
|
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 = []
|
LL = []
|
||||||
i = ord(c)
|
assert i<=256
|
||||||
counter = 8
|
counter = 8
|
||||||
while i:
|
while i:
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user