Skip to content

Commit

Permalink
Refs #40 - Moved "replace null" up to normalize function. Also fixed …
Browse files Browse the repository at this point in the history
…unit test.
  • Loading branch information
AVPS committed Jan 14, 2016
1 parent 4cba2a9 commit 4006638
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pyzor/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def handle_line(self, line):

@classmethod
def normalize(cls, s):
s = s.replace("\x00", "")
repl = cls.unwanted_txt_repl
s = cls.longstr_ptrn.sub(repl, s)
s = cls.email_ptrn.sub(repl, s)
Expand Down Expand Up @@ -157,8 +158,6 @@ def digest_payloads(cls, msg):
errors = "strict"

try:
if "\00" in payload:
payload = payload.replace("\x00", "")
payload = payload.decode(charset, errors)
except (LookupError, UnicodeError, AssertionError):
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def test_digest(self):
self.assertEqual(result, expected)

def test_digest_w_null(self):
message = b"That's some good ham rig ht there"
message = b"That's some good ham rig\x00ht there"
predigested = b"That'ssomegoodhamrightthere"

digest = hashlib.sha1()
Expand Down

0 comments on commit 4006638

Please sign in to comment.