spam blacklist moved to config file
This commit is contained in:
parent
dd00012758
commit
26c12c9024
1 changed files with 4 additions and 11 deletions
|
@ -41,6 +41,7 @@ db_uri = config.get("database", "uri")
|
||||||
connection = sqlobject.connectionForURI(db_uri)
|
connection = sqlobject.connectionForURI(db_uri)
|
||||||
sqlobject.sqlhub.processConnection = connection
|
sqlobject.sqlhub.processConnection = connection
|
||||||
loader = genshi.template.TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=False)
|
loader = genshi.template.TemplateLoader(os.path.join(BASE_DIR, 'templates'), auto_reload=False)
|
||||||
|
spam_blacklist = [item.strip() for item in config.get("spam", "blacklist").splitlines() if item.strip()]
|
||||||
|
|
||||||
BLOG_DIR = os.path.join(BASE_DIR, "blog")
|
BLOG_DIR = os.path.join(BASE_DIR, "blog")
|
||||||
|
|
||||||
|
@ -593,15 +594,7 @@ def check_spam_content(text):
|
||||||
return True
|
return True
|
||||||
if count_urls(text) > 2:
|
if count_urls(text) > 2:
|
||||||
return True
|
return True
|
||||||
blacklist = ("ativan","cialis","fioricet","Kamagra",
|
for keyword in spam_blacklist:
|
||||||
"levitra", "phentermine", "propecia", "semenax",
|
|
||||||
"Sildenafil", "slots", "tadalafil", "tramadol",
|
|
||||||
"vigrx", "viagra", "vimax", "xanax",
|
|
||||||
"Electronic cigarette", "online blackjack", "Online Bingo",
|
|
||||||
"Online casino", "online gambling", "Online roulette", "roulette online",
|
|
||||||
"poker online", "payday loans", "pokies", "reverse phone",
|
|
||||||
"preteen", "lolitas", "lolita", "teen nude")
|
|
||||||
for keyword in blacklist:
|
|
||||||
if keyword.lower() in text.lower():
|
if keyword.lower() in text.lower():
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -879,8 +872,8 @@ def submit_content(bobo_request, hash_key=None, submitter=None, content=None):
|
||||||
data = {}
|
data = {}
|
||||||
if content and check_spam_content(content):
|
if content and check_spam_content(content):
|
||||||
value_dict["errors"]["content"] = \
|
value_dict["errors"]["content"] = \
|
||||||
"Spam-Verdacht: Inhalt darf keine HTML-Tags und nicht " + \
|
"Spam-Verdacht: der Inhalt darf keine HTML-Tags, nicht " + \
|
||||||
"zuviele Links enthalten"
|
"zuviele Links und keine spam-typischen Worte enthalten"
|
||||||
else:
|
else:
|
||||||
data["content"] = content
|
data["content"] = content
|
||||||
if submitter and (not is_spam_submitter_name(submitter, value_dict["errors"])):
|
if submitter and (not is_spam_submitter_name(submitter, value_dict["errors"])):
|
||||||
|
|
Loading…
Reference in a new issue