Add a default blacklist for FancyCaptcha.

If a blacklist is not specified using the '--blacklist' command-line option,
captcha.py will use a default blacklist, included in this patch-set.

Bug: 21025
Change-Id: I93eeaead4a86b38cf5aa0049ac5e61e5b4935b58
This commit is contained in:
emufarmers 2013-03-10 20:57:12 -04:00 committed by Ori Livneh
parent 12c0a7b481
commit cd7106e0d9
2 changed files with 45 additions and 9 deletions

40
blacklist Normal file
View file

@ -0,0 +1,40 @@
altar
anus
ass
bitch
breast
butt
christ
cock
crazy
cross
cum
cunt
daemon
demon
dick
dumb
fuck
hag
holy
horny
idiot
jerk
jesus
lust
nerd
nigger
penis
piss
pussy
satan
sex
shit
smut
stupid
tit
tits
twat
vamp
whore
witch

View file

@ -183,6 +183,7 @@ if __name__ == '__main__':
To check a reply, hash it in the same way with the same salt and
secret key, then compare with the hash value given.
"""
script_dir = os.path.dirname(os.path.realpath(__file__))
parser = OptionParser()
parser.add_option("--wordlist", help="A list of words (required)", metavar="WORDS.txt")
parser.add_option("--random", help="Use random charcters instead of a wordlist", action="store_true")
@ -191,7 +192,7 @@ if __name__ == '__main__':
parser.add_option("--font", help="The font to use (required)", metavar="FONT.ttf")
parser.add_option("--font-size", help="The font size (default 40)", metavar="N", type='int', default=40)
parser.add_option("--count", help="The maximum number of images to make (default 20)", metavar="N", type='int', default=20)
parser.add_option("--blacklist", help="A blacklist of words that should not be used", metavar="FILE")
parser.add_option("--blacklist", help="A blacklist of words that should not be used", metavar="FILE", default=os.path.join(script_dir, "blacklist"))
parser.add_option("--fill", help="Fill the output directory to contain N files, overrides count, cannot be used with --dirs", metavar="N", type='int')
parser.add_option("--dirs", help="Put the images into subdirectories N levels deep - $wgCaptchaDirectoryLevels", metavar="N", type='int')
parser.add_option("--verbose", "-v", help="Show debugging information", action='store_true')
@ -220,7 +221,7 @@ if __name__ == '__main__':
else:
sys.exit("Need to specify the location of a font")
blacklistfile = opts.blacklist
blacklist = read_wordlist(opts.blacklist)
count = opts.count
fill = opts.fill
dirs = opts.dirs
@ -237,11 +238,6 @@ if __name__ == '__main__':
if len(x) in (4,5) and x[0] != "f"
and x[0] != x[1] and x[-1] != x[-2]]
if blacklistfile:
blacklist = read_wordlist(blacklistfile)
else:
blacklist = []
for i in range(count):
word = pick_word(words, blacklist, verbose, opts.number_words, opts.min_length, opts.max_length)
salt = "%08x" % random.randrange(2**32)