spam blacklist moved to config file

This commit is contained in:
lars 2013-02-23 15:18:33 +00:00
parent dd00012758
commit 26c12c9024

View file

@ -41,6 +41,7 @@ db_uri = config.get("database", "uri")
connection = sqlobject.connectionForURI(db_uri)
sqlobject.sqlhub.processConnection = connection
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")
@ -593,15 +594,7 @@ def check_spam_content(text):
return True
if count_urls(text) > 2:
return True
blacklist = ("ativan","cialis","fioricet","Kamagra",
"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:
for keyword in spam_blacklist:
if keyword.lower() in text.lower():
return True
return False
@ -879,8 +872,8 @@ def submit_content(bobo_request, hash_key=None, submitter=None, content=None):
data = {}
if content and check_spam_content(content):
value_dict["errors"]["content"] = \
"Spam-Verdacht: Inhalt darf keine HTML-Tags und nicht " + \
"zuviele Links enthalten"
"Spam-Verdacht: der Inhalt darf keine HTML-Tags, nicht " + \
"zuviele Links und keine spam-typischen Worte enthalten"
else:
data["content"] = content
if submitter and (not is_spam_submitter_name(submitter, value_dict["errors"])):