Skip to content

Commit

Permalink
Handle incomplete dotted quads
Browse files Browse the repository at this point in the history
  • Loading branch information
smontanaro committed Nov 20, 2017
1 parent 71a5350 commit 973b470
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spambayes/spambayes/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,12 +1729,15 @@ def gen_dotted_quad_clues(pfx, ips):
for ip in ips:
yield "%s:%s/32" % (pfx, ip)
dottedQuadList = ip.split(".")
yield "%s:%s/8" % (pfx, dottedQuadList[0])
yield "%s:%s.%s/16" % (pfx, dottedQuadList[0],
dottedQuadList[1])
yield "%s:%s.%s.%s/24" % (pfx, dottedQuadList[0],
dottedQuadList[1],
dottedQuadList[2])
if len(dottedQuadList) >= 1:
yield "%s:%s/8" % (pfx, dottedQuadList[0])
if len(dottedQuadList) >= 2:
yield "%s:%s.%s/16" % (pfx, dottedQuadList[0],
dottedQuadList[1])
if len(dottedQuadList) >= 3:
yield "%s:%s.%s.%s/24" % (pfx, dottedQuadList[0],
dottedQuadList[1],
dottedQuadList[2])

global_tokenizer = Tokenizer()
tokenize = global_tokenizer.tokenize

0 comments on commit 973b470

Please sign in to comment.