Skip to content

Commit

Permalink
Merge pull request #1170 from quartata/dots
Browse files Browse the repository at this point in the history
Make mostly dots calculate length *before* stripping code blocks
  • Loading branch information
ArtOfCode- committed Oct 25, 2017
2 parents 0b059ab + 11deab9 commit 4b4bb40
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion findspam.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ def mostly_dots(s, site, *args):
body = strip_urls_and_tags(s)
body_length = len(body)

body = regex.sub("(?s)<pre>.*?</pre>", "", body)
body = regex.sub("(?s)<code>.*?</code>", "", body)

dot_count = len(regex.findall(r"\.", body))

if body_length and dot_count / float(body_length) >= 0.4:
Expand Down Expand Up @@ -1065,7 +1068,7 @@ class FindSpam:
# Mostly dots in post
{'method': mostly_dots, 'all': True, 'sites': ['codegolf.stackexchange.com'],
'reason': 'mostly dots in {}', 'title': True, 'body': True, 'username': False, 'body_summary': False,
'stripcodeblocks': True, 'max_rep': 50, 'max_score': 0},
'stripcodeblocks': False, 'max_rep': 50, 'max_score': 0},

#
# Category: other
Expand Down

0 comments on commit 4b4bb40

Please sign in to comment.