Skip to content

Commit bffd4f4

Browse files
committed
Fixed codec: whitespace_after_before
1 parent 1283db5 commit bffd4f4

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

codext/stegano/whitespace.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ def wsba_decode(p):
5151
eq = "ord(c)" + "".join({'-':"+",'+':"-"}.get(c, c) for c in p)
5252
def decode(text, errors="strict"):
5353
s = ""
54-
for line in text.split("\n"):
55-
if len(line.strip()) == 0:
54+
for i, l in enumerate(text.split("\n")):
55+
ll = len(l.strip())
56+
if ll == 0:
5657
continue
57-
after = len(line) - len(line.rstrip(" "))
58-
before = len(line) - len(line.lstrip(" "))
59-
c = line[before]
58+
if ll > 1:
59+
s += handle_error("whitespace_after_before", errors, decode=True, item="line")(l, i)
60+
after = len(l) - len(l.rstrip(" "))
61+
before = len(l) - len(l.lstrip(" "))
62+
c = l[before]
6063
s += chr(eval(eq))
61-
return s, len(s)
64+
return s, len(text)
6265
return decode
6366

6467

0 commit comments

Comments
 (0)