Skip to content

Commit

Permalink
Get rid of unused profanity filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
spladug committed Nov 21, 2011
1 parent 935d0c0 commit ee9ee8b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 35 deletions.
2 changes: 0 additions & 2 deletions r2/example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ translator_password =
takedown_sr = _takedowns
# png compressor
png_optimizer = /usr/bin/env optipng
# bad words that should be *'d out
profanity_wordlist =

# -- search --
# where is solor?
Expand Down
10 changes: 0 additions & 10 deletions r2/r2/lib/app_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,6 @@ def reset_caches():
print ("Warning: g.media_domain == g.domain. " +
"This may give untrusted content access to user cookies")

self.profanities = None
if self.profanity_wordlist and os.path.exists(self.profanity_wordlist):
with open(self.profanity_wordlist, 'r') as handle:
words = []
for line in handle:
words.append(line.strip(' \n\r'))
if words:
self.profanities = re.compile(r"\b(%s)\b" % '|'.join(words),
re.I | re.U)

self.reddit_host = socket.gethostname()
self.reddit_pid = os.getpid()

Expand Down
16 changes: 0 additions & 16 deletions r2/r2/lib/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ def markdown_souptest(text, nofollow=False, target=None):
#TODO markdown should be looked up in batch?
#@memoize('markdown')
def safemarkdown(text, nofollow=False, target=None, wrap=True):
if c.user.pref_no_profanity:
text = profanity_filter(text)

if not text:
return None

Expand All @@ -234,16 +231,3 @@ def keep_space(text):

def unkeep_space(text):
return text.replace(' ', ' ').replace('
', '\n').replace('	', '\t')


def profanity_filter(text):
def _profane(m):
x = m.group(1)
return ''.join(u"\u2731" for i in xrange(len(x)))

if g.profanities:
try:
return g.profanities.sub(_profane, text)
except UnicodeDecodeError:
return text
return text
8 changes: 1 addition & 7 deletions r2/r2/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from printable import Printable
from r2.config import cache
from r2.lib.memoize import memoize
from r2.lib.filters import profanity_filter, _force_utf8
from r2.lib.filters import _force_utf8
from r2.lib import utils
from r2.lib.log import log_text
from mako.filters import url_escape
Expand Down Expand Up @@ -449,9 +449,6 @@ def add_props(cls, user, wrapped):
else:
item.nofollow = False

if c.user.pref_no_profanity:
item.title = profanity_filter(item.title)

item.subreddit_path = item.subreddit.path
if cname:
item.subreddit_path = ("http://" +
Expand Down Expand Up @@ -1124,9 +1121,6 @@ def add_props(cls, user, wrapped):
elif item.sr_id is not None:
item.subreddit = m_subreddits[item.sr_id]

if c.user.pref_no_profanity:
item.subject = profanity_filter(item.subject)

item.is_collapsed = None
if not item.new:
if item.recipient:
Expand Down

0 comments on commit ee9ee8b

Please sign in to comment.