Skip to content

Commit 769b44a

Browse files
committed
read bad words file in binary mode because the body is also bytes
1 parent 08e4cce commit 769b44a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sogs/filtration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
def should_drop_message_with_body(body):
77
"""return true if we should drop a message given its body"""
8+
body = message_body(body)
9+
if body is None:
10+
return False
811
if os.path.exists(config.BAD_WORDS_FILE):
9-
body = message_body(body)
10-
with open(config.BAD_WORDS_FILE, 'r') as f:
12+
with open(config.BAD_WORDS_FILE, 'rb') as f:
1113
for line in f:
1214
word = line.rstrip()
1315
if word in body:

0 commit comments

Comments
 (0)