Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip code block in mostly-img reason #4190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions findspam.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,19 @@ def len_img_block(string):
# max_score=2 to prevent voting fraud
@create_rule("post is mostly images", title=False, max_rep=201, max_score=2)
def mostly_img(s, site):
if len(s) == 0:
s_len_orig = len(s)
if s_len_orig == 0:
return False, ""

# Strip code blocks manually. This should be removed once feature
# https://chat.stackexchange.com/transcript/message/54842978
# get implemented.
s = regex.sub("(?s)<pre>.*?</pre>", "\nstripped pre\n", s)
s = regex.sub("(?s)<code>.*?</code>", "\nstripped code\n", s)

s_len_img = len_img_block(s)
if s_len_img / len(s) > IMG_TXT_R_THRES:
return True, "{:.4f} of the post is html image blocks".format(s_len_img / len(s))
if s_len_img / s_len_orig > IMG_TXT_R_THRES:
return True, "{:.4f} of the post is html image blocks".format(s_len_img / s_len_orig)
return False, ""


Expand Down