diff --git a/.gitignore b/.gitignore index 0f81d60..cb2ee4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -**.DS_Store \ No newline at end of file +**.DS_Store +.vscode +coverage \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2381eaf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "5" + - "5.1" + - "4" + - "4.2" + - "4.1" + - "4.0" +after_success: 'npm run coveralls' \ No newline at end of file diff --git a/README.md b/README.md index 7a32e02..f9a2250 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Node.js Profanity Utility +[![Build Status](https://travis-ci.org/wagoid/nodejs-profanity-util.svg?branch=master)](https://travis-ci.org/wagoid/nodejs-profanity-util) +[![Coverage Status](https://coveralls.io/repos/github/wagoid/nodejs-profanity-util/badge.svg?branch=master)](https://coveralls.io/github/wagoid/nodejs-profanity-util?branch=master) + > Utility for detection, filtering and replacement / obscuration of forbidden words -The original list of swearwords used by default was taken from [here](https://gist.github.com/jamiew/1112488). +The original lists of swearwords used by default were taken from [here](https://gist.github.com/jamiew/1112488) and [here](https://github.com/shutterstock/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words). **Please note:** This small utility module is written to prevent or monitor the use of certain words in your content without keeping context in account. An improper use may compromise the meaning of your content. Keep in account when using. @@ -12,13 +15,15 @@ The original list of swearwords used by default was taken from [here](https://gi ## API -### `profanity.check(target_string, [ forbidden_list ])` +### `profanity.check(target_string, [languages], [ forbidden_list ])` +#####async version is also available: `profanity.checkAsync(target_string, [languages], [ forbidden_list ])` Returns a list of forbidden words found in a string. **Arguments** * `target_string` - String to search +* `languages` (Optional )- Array of languages to check words from. Accepts a string if just one language is needed. * `forbidden_list` (Optional) - Array containing forbidden terms **Example** @@ -30,7 +35,24 @@ console.log(profanity.check('Lorem ipsum foo bar poop test poop damn dolor sit.. // [ 'poop', 'poop', 'damn' ] ``` +Or the async method: + +```javascript +var profanity = require('profanity-util'); + +profanity.checkAsync('Lorem ipsum foo bar poop test poop damn dolor sit..') + .then(function (result) { + console.log(result); + // [ 'poop', 'poop', 'damn' ] + }) + .catch(function (err) { + console.log('Something went wrong.'); + }); +``` + + ### `profanity.purify(target, [ options ])` +#####async version is also available: `profanity.purifyAsync(target, [ options ])` Purifies a string or strings contained in a given object or array from forbidden words. @@ -51,9 +73,11 @@ The .purify method will return an Array containing two values: **Options** * `forbiddenList` - Array of forbidden terms to replace or obscure +* `languages` - Array of languages to check words from. Accepts a string if just one language is needed. * `replacementsList` - Array of replacement words (To pick randomly from) * `obscureSymbol` - Symbol used to obscure words if `obscured` is set to true * `replace`- If set to true it will replace forbidden words (E.g. a*****b) instead of obscuring them +* `maxRecursionDepth` - If you are passing objects, a recursive iteration will be performed to fiind all strings inside it. You can set the maximum depth of the recursion. **Examples** @@ -72,6 +96,21 @@ console.log(profanity.purify({ // [ { foo: 'p**p', bar: { nested: 'd**n', arr: [ 'foo', 'p**p' ] } }, [ 'poop', 'damn', 'poop' ] ] ``` +Async version: + +```javascript +var profanity = require('profanity-util'); + +profanity.purify('lorem ipsum foo damn bar poop') + .then(function (result) { + console.log(result); + // [ 'lorem ipsum foo d**n bar p**p, [ 'damn', 'poop' ] ] + }) + .catch(function (err) { + console.log('Something went wrong.'); + }); +``` + **Obscure mode, custom options** ```javascript diff --git a/lib/profanity.js b/lib/profanity.js index 2edbed6..4f71c68 100644 --- a/lib/profanity.js +++ b/lib/profanity.js @@ -3,120 +3,228 @@ Copyright (C) 2014 Kano Computing Ltd. License: http://opensource.org/licenses/MIT The MIT License (MIT) */ -var swearwords = require('./swearwords.json'), - util = require('./util'); +var util = require('./util'); +var fs = require('fs'); +var _ = require('underscore'); +var path = require('path'); +var Promise = require('bluebird'); var DEFAULT_REPLACEMENTS = [ - 'bunnies', - 'butterfly', - 'kitten', - 'love', - 'gingerly', - 'flowers', - 'puppy', - 'joyful', - 'rainbows', - 'unicorn' - ], - DEFAULT_REGEX = getListRegex(swearwords); - -function getListRegex (list) { - // we want to treat all characters in the word as literals, not as regex specials (e.g. shi+) - function escapeRegexChars(word) { return word.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); }; - return new RegExp('\\b(' + list.map(escapeRegexChars).join('|') + ')\\b', 'gi'); + 'bunnies', + 'butterfly', + 'kitten', + 'love', + 'gingerly', + 'flowers', + 'puppy', + 'joyful', + 'rainbows', + 'unicorn' +]; +var DEFAULT_LANGUAGES = ['en']; +var AVAILABLE_LANGUAGES = ['ar', 'cs', 'da', 'de', 'en', 'eo', 'es', 'fa', 'fi', 'fr', 'hi', 'hu', 'it', 'ja', 'ko', 'nl', 'no', 'pl', 'pt', 'ru', 'sv', 'th', 'tlh', 'tr', 'zh']; +var DEFAULT_FS_OPTIONS = {encoding: 'utf8' }; +var SWEARWORDS_DIR = path.join(__dirname, 'swearwords'); + +function getWordListsPromises (languages) { + var promises = []; + _.each(languages, function(language) { + promises.push(util.promisiFyReadJsonFile(path.join(SWEARWORDS_DIR, language + '.json'), DEFAULT_FS_OPTIONS)); + }); + + return promises; } -function check (target, forbiddenList) { - var targets = [], - regex = forbiddenList ? getListRegex(forbiddenList) : DEFAULT_REGEX; - - if (typeof target === 'string') { - targets.push(target); - } else if (typeof target === 'object') { +function getWordListsConcatenated (languages) { + var lists = []; + + _.each(languages, function (language) { + lists = lists.concat(JSON.parse(fs.readFileSync(path.join(SWEARWORDS_DIR, language + '.json'), DEFAULT_FS_OPTIONS))); + }); + + return lists; +} - util.eachRecursive(target, function (val) { - if (typeof val === 'string') { - targets.push(val); - } - }); - } +function escapeRegexChars (word) { + return word.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); +} - return targets.join(' ').match(regex) || []; +function getListRegexAsync (list, languages) { + if (list) { + return new Promise(function (resolve, reject) { + resolve(_getListRegex(list)); + }); + } else { + return Promise.all(getWordListsPromises(languages)) + .then(function (listsArray) { + var listRegex = []; + _.each(listsArray, function (lst) { + listRegex = listRegex.concat(lst); + }); + + return _getListRegex(listRegex); + }); + } } -function purifyString (str, options) { - options = options || {}; +function getListRegex (list, languages) { + if (!list) { + list = getWordListsConcatenated(languages); + } + + return _getListRegex(list); +} - var matches = [], - purified, - forbiddenList = options.forbiddenList || null, - replacementsList = options.replacementsList || DEFAULT_REPLACEMENTS, - regex = forbiddenList ? getListRegex(forbiddenList) : DEFAULT_REGEX, - replace = options.replace || false, - obscureSymbol = options.obscureSymbol || '*'; +function _getListRegex(list) { + // we want to treat all characters in the word as literals, not as regex specials (e.g. shi+) + return new RegExp('\\b(' + list.map(escapeRegexChars).join('|') + ')\\b', 'gi'); +} - purified = str.replace(regex, function (val) { - matches.push(val); +function getDefaultLanguagesValue (languages) { + if (_.isString(languages)) { + if (languages.toLowerCase() === 'all') { + languages = AVAILABLE_LANGUAGES; + } else { + languages = [languages]; + } + } else if (!languages) { + languages = DEFAULT_LANGUAGES; + } + + return languages; +} - if (replace) { - return replacementsList[Math.floor(Math.random() * replacementsList.length)]; - } +function check (target, languages, forbiddenList) { + languages = getDefaultLanguagesValue(languages); - var str = val.substr(0, 1); + var regex = getListRegex(forbiddenList, languages); - for (var i = 0; i < val.length - 2; i += 1) { - str += obscureSymbol; - } + return _check(target, regex); +} - return str + val.substr(-1); +function _check (target, regex) { + var targets = []; + + if (_.isString(target)) { + targets.push(target); + /* istanbul ignore else */ + } else if (_.isObject(target)) { + util.eachRecursive(target, function(val) { + /* istanbul ignore else */ + if (_.isString(val)) { + targets.push(val); + } }); + } + return targets.join(' ').match(regex) || []; +} - return [ purified, matches ]; +function checkAsync (target, languages, forbiddenList) { + languages = getDefaultLanguagesValue(languages); + + return getListRegexAsync(forbiddenList, languages) + .then(function (regex) { + var result = _check(target, regex); + return result; + }); } -function purify (target, options) { - options = options || {}; +function purifyString (str, regex, options) { + var matches = [], + purified, + replace = options.replace || false, + obscureSymbol = options.obscureSymbol || '*'; - var matches = [], - fields = options.fields || ( target instanceof Object ? Object.keys(target) : [] ), - result; + purified = str.replace(regex, function(val) { + matches.push(val); - if (typeof target === 'string') { + if (replace) { + return options.replacementsList[Math.floor(Math.random() * options.replacementsList.length)]; + } - return purifyString(target, options); + var str = val.substr(0, 1); - } else if (typeof target === 'object') { - fields.forEach(function (field) { + for (var i = 0; i < val.length - 2; i += 1) { + str += obscureSymbol; + } - // TODO: Use better recursive checking, make DRYer - if (typeof target[field] === 'string') { + return str + val.substr(-1); + }); - result = purifyString(target[field], options); - target[field] = result[0]; - matches = matches.concat(result[1]); + return [purified, matches]; +} - } else if (typeof target[field] === 'object') { - util.eachRecursive(target[field], function (val, key, root) { +function _purify (target, fields, regex, options) { + var matches = []; + var result; + + if (_.isString(target)) { + + return purifyString(target, regex, options); + + /* istanbul ignore else */ + } else if (_.isObject(target)) { + _.each(fields, function(field) { + + // TODO: Use better recursive checking, make DRYer + if (_.isString(target[field])) { + + result = purifyString(target[field], regex, options); + target[field] = result[0]; + matches = matches.concat(result[1]); + /* istanbul ignore else */ + } else if (_.isObject(target[field])) { + util.eachRecursive(target[field], function(val, key, root) { + /* istanbul ignore else */ + if (_.isString(val)) { + result = purifyString(val, regex, options); + root[key] = result[0]; + matches = matches.concat(result[1]); + } + + }, options.maxRecursionDepth); + } + }); - if (fields && fields.indexOf(key) === -1) { - return; - } + return [target, matches]; + } +} - if (typeof val === 'string') { - result = purifyString(val, options); - root[key] = result[0]; - matches = matches.concat(result[1]); - } +function getReplacementsList (options) { + var replacementsList = options.replacementsList; + if (!_.isArray(replacementsList) || _.isEmpty(replacementsList)) { + replacementsList = DEFAULT_REPLACEMENTS; + } + + return replacementsList; +} - }); - } - }); +function purify (target, options) { + options = options || {}; + options.languages = getDefaultLanguagesValue(options.languages); + options.replacementsList = getReplacementsList(options); + + var fields = options.fields || (target instanceof Object ? Object.keys(target) : []), + regex = getListRegex(options.forbiddenList, options.languages); + + return _purify(target, fields, regex, options); +} - return [ target, matches ]; - } +function purifyAsync (target, options) { + options = options || {}; + options.languages = getDefaultLanguagesValue(options.languages); + options.replacementsList = getReplacementsList(options); + + var fields = options.fields || (target instanceof Object ? Object.keys(target) : []); + return getListRegexAsync(options.forbiddenList, options.languages) + .then(function (regex) { + return _purify(target, fields, regex, options); + }); } module.exports = { - check: check, - purify: purify + check: check, + checkAsync: checkAsync, + purify: purify, + purifyAsync: purifyAsync }; \ No newline at end of file diff --git a/lib/swearwords/ar.json b/lib/swearwords/ar.json new file mode 100644 index 0000000..f7d6e66 --- /dev/null +++ b/lib/swearwords/ar.json @@ -0,0 +1,40 @@ +[ + "سكس", + "طيز", + "شرج", + "لعق", + "لحس", + "مص", + "تمص", + "بيضان", + "ثدي", + "بز", + "بزاز", + "حلمة", + "مفلقسة", + "بظر", + "كس", + "فرج", + "شهوة", + "شاذ", + "مبادل", + "عاهرة", + "جماع", + "قضيب", + "زب", + "لوطي", + "لواط", + "سحاق", + "سحاقية", + "اغتصاب", + "خنثي", + "احتلام", + "نيك", + "متناك", + "متناكة", + "شرموطة", + "عرص", + "خول", + "قحبة", + "لبوة" +] \ No newline at end of file diff --git a/lib/swearwords/cs.json b/lib/swearwords/cs.json new file mode 100644 index 0000000..a655b94 --- /dev/null +++ b/lib/swearwords/cs.json @@ -0,0 +1,43 @@ +[ + "bordel", + "buzna", + "čumět", + "čurák", + "debil", + "do piče", + "do prdele", + "dršťka", + "držka", + "flundra", + "hajzl", + "hovno", + "chcanky", + "chuj", + "jebat", + "kokot", + "kokotina", + "koňomrd", + "kunda", + "kurva", + "mamrd", + "mrdat", + "mrdka", + "mrdník", + "oslošoust", + "piča", + "píčus", + "píchat", + "pizda", + "prcat", + "prdel", + "prdelka", + "sračka", + "srát", + "šoustat", + "šulin", + "vypíčenec", + "zkurvit", + "zkurvysyn", + "zmrd", + "žrát" +] \ No newline at end of file diff --git a/lib/swearwords/da.json b/lib/swearwords/da.json new file mode 100644 index 0000000..e423b8a --- /dev/null +++ b/lib/swearwords/da.json @@ -0,0 +1,22 @@ +[ + "anus", + "bøsserøv", + "cock", + "fisse", + "fissehår", + "fuck", + "hestepik", + "kussekryller", + "lort", + "luder", + "pik", + "pikhår", + "pikslugeri", + "piksutteri", + "pis", + "røv", + "røvhul", + "røvskæg", + "røvspræke", + "shit" +] \ No newline at end of file diff --git a/lib/swearwords/de.json b/lib/swearwords/de.json new file mode 100644 index 0000000..a0dfa96 --- /dev/null +++ b/lib/swearwords/de.json @@ -0,0 +1,67 @@ +[ + "analritter", + "arsch", + "arschficker", + "arschlecker", + "arschloch", + "bimbo", + "bratze", + "bumsen", + "bonze", + "dödel", + "fick", + "ficken", + "flittchen", + "fotze", + "fratze", + "hackfresse", + "hure", + "hurensohn", + "ische", + "kackbratze", + "kacke", + "kacken", + "kackwurst", + "kampflesbe", + "kanake", + "kimme", + "lümmel", + "MILF", + "möpse", + "morgenlatte", + "möse", + "mufti", + "muschi", + "nackt", + "neger", + "nigger", + "nippel", + "nutte", + "onanieren", + "orgasmus", + "pimmel", + "pimpern", + "pinkeln", + "pissen", + "pisser", + "popel", + "poppen", + "porno", + "reudig", + "rosette", + "schabracke", + "schlampe", + "scheiße", + "scheisser", + "schiesser", + "schnackeln", + "schwanzlutscher", + "schwuchtel", + "tittchen", + "titten", + "vögeln", + "vollpfosten", + "wichse", + "wichsen", + "wichser" +] \ No newline at end of file diff --git a/lib/swearwords.json b/lib/swearwords/en.json similarity index 100% rename from lib/swearwords.json rename to lib/swearwords/en.json diff --git a/lib/swearwords/eo.json b/lib/swearwords/eo.json new file mode 100644 index 0000000..2f7145d --- /dev/null +++ b/lib/swearwords/eo.json @@ -0,0 +1,39 @@ +[ + "bugren", + "bugri", + "bugru", + "ĉiesulino", + "ĉiesulo", + "diofek", + "diofeka", + "fek", + "feken", + "fekfikanto", + "feklekulo", + "fekulo", + "fik", + "fikado", + "fikema", + "fikfek", + "fiki", + "fikiĝi", + "fikiĝu", + "fikilo", + "fikklaŭno", + "fikota", + "fiku", + "forfiki", + "forfikiĝu", + "forfiku", + "forfurzu", + "forpisi", + "forpisu", + "furzulo", + "kacen", + "kaco", + "kacsuĉulo", + "kojono", + "piĉen", + "piĉo", + "zamenfek" +] \ No newline at end of file diff --git a/lib/swearwords/es.json b/lib/swearwords/es.json new file mode 100644 index 0000000..4d63118 --- /dev/null +++ b/lib/swearwords/es.json @@ -0,0 +1,70 @@ +[ + "Asesinato", + "asno", + "bastardo", + "Bollera", + "Cabron", + "Cabrón", + "Caca", + "Chupada", + "Chupapollas", + "Chupetón", + "concha", + "Concha de tu madre", + "Coño", + "Coprofagía", + "Culo", + "Drogas", + "Esperma", + "Fiesta de salchichas", + "Follador", + "Follar", + "Gilipichis", + "Gilipollas", + "Hacer una paja", + "Haciendo el amor", + "Heroína", + "Hija de puta", + "Hijaputa", + "Hijo de puta", + "Hijoputa", + "Idiota", + "Imbécil", + "infierno", + "Jilipollas", + "Kapullo", + "Lameculos", + "Maciza", + "Macizorra", + "maldito", + "Mamada", + "Marica", + "Maricón", + "Mariconazo", + "martillo", + "Mierda", + "Nazi", + "Orina", + "Pedo", + "Pervertido", + "Pezón", + "Pinche", + "Pis", + "Prostituta", + "Puta", + "Racista", + "Ramera", + "Sádico", + "Semen", + "Sexo", + "Sexo oral", + "Soplagaitas", + "Soplapollas", + "Tetas grandes", + "Tía buena", + "Travesti", + "Trio", + "Verga", + "vete a la mierda", + "Vulva" +] \ No newline at end of file diff --git a/lib/swearwords/fa.json b/lib/swearwords/fa.json new file mode 100644 index 0000000..b77f3c3 --- /dev/null +++ b/lib/swearwords/fa.json @@ -0,0 +1,47 @@ +[ + "آب کیر", + "ارگاسم", + "برهنه", + "پورن", + "پورنو", + "تجاوز", + "تخمی", + "جق", + "جقی", + "جلق", + "جنده", + "چوچول", + "حشر", + "حشری", + "داف", + "دودول", + "ساک زدن", + "سکس", + "سکس کردن", + "سکسی", + "سوپر", + "شق کردن", + "شهوت", + "شهوتی", + "شونبول", + "فیلم سوپر", + "کس", + "کس دادن", + "کس کردن", + "کسکش", + "کوس", + "کون", + "کون دادن", + "کون کردن", + "کونکش", + "کونی", + "کیر", + "کیری", + "لاپا", + "لاپایی", + "لاشی", + "لخت", + "لش", + "منی", + "هرزه" +] \ No newline at end of file diff --git a/lib/swearwords/fi.json b/lib/swearwords/fi.json new file mode 100644 index 0000000..af862f8 --- /dev/null +++ b/lib/swearwords/fi.json @@ -0,0 +1,132 @@ +[ + "alfred nussi", + "bylsiä", + "haahka", + "haista paska", + "haista vittu", + "hatullinen", + "helvetisti", + "hevonkuusi", + "hevonpaska", + "hevonperse", + "hevonvittu", + "hevonvitunperse", + "hitosti", + "hitto", + "huorata", + "hässiä", + "juosten kustu", + "jutku", + "jutsku", + "jätkä", + "kananpaska", + "koiranpaska", + "kuin esterin perseestä", + "kulli", + "kullinluikaus", + "kuppainen", + "kusaista", + "kuseksia", + "kusettaa", + "kusi", + "kusipää", + "kusta", + "kyrpiintynyt", + "kyrpiintyä", + "kyrpiä", + "kyrpä", + "kyrpänaama", + "kyrvitys", + "lahtari", + "lutka", + "molo", + "molopää", + "mulkero", + "mulkku", + "mulkvisti", + "muna", + "munapää", + "munaton", + "mutakuono", + "mutiainen", + "naida", + "nainti", + "narttu", + "neekeri", + "nekru", + "nuolla persettä", + "nussia", + "nussija", + "nussinta", + "paljaalla", + "palli", + "pallit", + "paneskella", + "panettaa", + "panna", + "pano", + "pantava", + "paska", + "paskainen", + "paskamainen", + "paskanmarjat", + "paskantaa", + "paskapuhe", + "paskapää", + "paskattaa", + "paskiainen", + "paskoa", + "pehko", + "pentele", + "perkele", + "perkeleesti", + "persaukinen", + "perse", + "perseennuolija", + "perseet olalla", + "persereikä", + "perseääliö", + "persläpi", + "perspano", + "persvako", + "pilkunnussija", + "pillu", + "pillut", + "pipari", + "piru", + "pistää", + "pyllyvako", + "reikä", + "reva", + "ripsipiirakka", + "runkata", + "runkkari", + "runkkaus", + "runkku", + "ryssä", + "rättipää", + "saatanasti", + "suklaaosasto", + "tavara", + "toosa", + "tuhkaluukku", + "tumputtaa", + "turpasauna", + "tussu", + "tussukka", + "tussut", + "vakipano", + "vetää käteen", + "viiksi", + "vittu", + "vittuilla", + "vittuilu", + "vittumainen", + "vittuuntua", + "vittuuntunut", + "vitun", + "vitusti", + "vituttaa", + "vitutus", + "äpärä" +] \ No newline at end of file diff --git a/lib/swearwords/fr.json b/lib/swearwords/fr.json new file mode 100644 index 0000000..7b85676 --- /dev/null +++ b/lib/swearwords/fr.json @@ -0,0 +1,93 @@ +[ + "baiser", + "bander", + "bigornette", + "bite", + "bitte", + "bloblos", + "bordel", + "bosser", + "bourré", + "bourrée", + "brackmard", + "branlage", + "branler", + "branlette", + "branleur", + "branleuse", + "brouter le cresson", + "caca", + "cailler", + "chatte", + "chiasse", + "chier", + "chiottes", + "clito", + "clitoris", + "con", + "connard", + "connasse", + "conne", + "couilles", + "cramouille", + "cul", + "déconne", + "déconner", + "drague", + "emmerdant", + "emmerder", + "emmerdeur", + "emmerdeuse", + "enculé", + "enculée", + "enculeur", + "enculeurs", + "enfoiré", + "enfoirée", + "étron", + "fille de pute", + "fils de pute", + "folle", + "foutre", + "gerbe", + "gerber", + "gouine", + "grande folle", + "grogniasse", + "gueule", + "jouir", + "la putain de ta mère", + "MALPT", + "ménage à trois", + "merde", + "merdeuse", + "merdeux", + "meuf", + "nègre", + "nique ta mère", + "nique ta race", + "palucher", + "pédale", + "pédé", + "péter", + "pipi", + "pisser", + "pouffiasse", + "pousse-crotte", + "putain", + "pute", + "ramoner", + "sac à merde", + "salaud", + "salope", + "suce", + "tapette", + "teuf", + "tringler", + "trique", + "trou du cul", + "turlute", + "veuve", + "zigounette", + "zizi" +] \ No newline at end of file diff --git a/lib/swearwords/hi.json b/lib/swearwords/hi.json new file mode 100644 index 0000000..3d0a9af --- /dev/null +++ b/lib/swearwords/hi.json @@ -0,0 +1,98 @@ +[ + "aand", + "aandu", + "balatkar", + "beti chod", + "bhadva", + "bhadve", + "bhandve", + "bhootni ke", + "bhosad", + "bhosadi ke", + "boobe", + "chakke", + "chinaal", + "chinki", + "chod", + "chodu", + "chodu bhagat", + "chooche", + "choochi", + "choot", + "choot ke baal", + "chootia", + "chootiya", + "chuche", + "chuchi", + "chudai khanaa", + "chudan chudai", + "chut", + "chut ke baal", + "chut ke dhakkan", + "chut maarli", + "chutad", + "chutadd", + "chutan", + "chutia", + "chutiya", + "gaand", + "gaandfat", + "gaandmasti", + "gaandufad", + "gandu", + "gashti", + "gasti", + "ghassa", + "ghasti", + "harami", + "haramzade", + "hawas", + "hawas ke pujari", + "hijda", + "hijra", + "jhant", + "jhant chaatu", + "jhant ke baal", + "jhantu", + "kamine", + "kaminey", + "kanjar", + "kutta", + "kutta kamina", + "kutte ki aulad", + "kutte ki jat", + "kuttiya", + "loda", + "lodu", + "lund", + "lund choos", + "lund khajoor", + "lundtopi", + "lundure", + "maa ki chut", + "maal", + "madar chod", + "mooh mein le", + "mutth", + "najayaz", + "najayaz aulaad", + "najayaz paidaish", + "paki", + "pataka", + "patakha", + "raand", + "randi", + "saala", + "saala kutta", + "saali kutti", + "saali randi", + "suar", + "suar ki aulad", + "tatte", + "tatti", + "teri maa ka bhosada", + "teri maa ka boba chusu", + "teri maa ki chut", + "tharak", + "tharki" +] \ No newline at end of file diff --git a/lib/swearwords/hu.json b/lib/swearwords/hu.json new file mode 100644 index 0000000..d12e340 --- /dev/null +++ b/lib/swearwords/hu.json @@ -0,0 +1,98 @@ +[ + "balfasz", + "balfaszok", + "balfaszokat", + "balfaszt", + "barmok", + "barmokat", + "barmot", + "barom", + "baszik", + "bazmeg", + "buksza", + "bukszák", + "bukszákat", + "bukszát", + "búr", + "búrok", + "csöcs", + "csöcsök", + "csöcsöket", + "csöcsöt", + "fasz", + "faszfej", + "faszfejek", + "faszfejeket", + "faszfejet", + "faszok", + "faszokat", + "faszt", + "fing", + "fingok", + "fingokat", + "fingot", + "franc", + "francok", + "francokat", + "francot", + "geci", + "gecibb", + "gecik", + "geciket", + "gecit", + "kibaszott", + "kibaszottabb", + "kúr", + "kurafi", + "kurafik", + "kurafikat", + "kurafit", + "kurva", + "kurvák", + "kurvákat", + "kurvát", + "leggecibb", + "legkibaszottabb", + "legszarabb", + "marha", + "marhák", + "marhákat", + "marhát", + "megdöglik", + "pele", + "pelék", + "picsa", + "picsákat", + "picsát", + "pina", + "pinák", + "pinákat", + "pinát", + "pofa", + "pofákat", + "pofát", + "pöcs", + "pöcsök", + "pöcsöket", + "pöcsöt", + "punci", + "puncik", + "segg", + "seggek", + "seggeket", + "segget", + "seggfej", + "seggfejek", + "seggfejeket", + "seggfejet", + "szajha", + "szajhák", + "szajhákat", + "szajhát", + "szar", + "szarabb", + "szarik", + "szarok", + "szarokat", + "szart" +] \ No newline at end of file diff --git a/lib/swearwords/it.json b/lib/swearwords/it.json new file mode 100644 index 0000000..ba3da42 --- /dev/null +++ b/lib/swearwords/it.json @@ -0,0 +1,182 @@ +[ + "allupato", + "ammucchiata", + "anale", + "arrapato", + "arrusa", + "arruso", + "assatanato", + "bagascia", + "bagassa", + "bagnarsi", + "baldracca", + "balle", + "battere", + "battona", + "belino", + "biga", + "bocchinara", + "bocchino", + "bofilo", + "boiata", + "bordello", + "brinca", + "bucaiolo", + "budiùlo", + "buona donna", + "busone", + "cacca", + "caccati in mano e prenditi a schiaffi", + "caciocappella", + "cadavere", + "cagare", + "cagata", + "cagna", + "cammello", + "cappella", + "carciofo", + "carità", + "casci", + "cazzata", + "cazzimma", + "cazzo", + "checca", + "chiappa", + "chiavare", + "chiavata", + "ciospo", + "ciucciami il cazzo", + "coglione", + "coglioni", + "cornuto", + "cozza", + "culattina", + "culattone", + "culo", + "di merda", + "ditalino", + "duro", + "fare unaŠ", + "fava", + "femminuccia", + "fica", + "figa", + "figlio di buona donna", + "figlio di puttana", + "figone", + "finocchio", + "fottere", + "fottersi", + "fracicone", + "fregna", + "frocio", + "froscio", + "fuori come un balcone", + "goldone", + "grilletto", + "guanto", + "guardone", + "incazzarsi", + "incoglionirsi", + "ingoio", + "l'arte bolognese", + "leccaculo", + "lecchino", + "lofare", + "loffa", + "loffare", + "lumaca", + "manico", + "mannaggia", + "merda", + "merdata", + "merdoso", + "mignotta", + "minchia", + "minchione", + "mona", + "monta", + "montare", + "mussa", + "nave scuola", + "nerchia", + "nudo", + "padulo", + "palle", + "palloso", + "patacca", + "patonza", + "pecorina", + "pesce", + "picio", + "pincare", + "pipa", + "pipì", + "pippone", + "pirla", + "pisciare", + "piscio", + "pisello", + "pistola", + "pistolotto", + "pomiciare", + "pompa", + "pompino", + "porca", + "porca madonna", + "porca miseria", + "porca puttana", + "porco due", + "porco zio", + "potta", + "puppami", + "puttana", + "quaglia", + "recchione", + "regina", + "rincoglionire", + "rizzarsi", + "rompiballe", + "ruffiano", + "sbattere", + "sbattersi", + "sborra", + "sborrata", + "sborrone", + "sbrodolata", + "scopare", + "scopata", + "scorreggiare", + "sega", + "slinguare", + "slinguata", + "smandrappata", + "soccia", + "socmel", + "sorca", + "spagnola", + "spompinare", + "sticchio", + "stronza", + "stronzata", + "stronzo", + "succhiami", + "sveltina", + "sverginare", + "tarzanello", + "terrone", + "testa di cazzo", + "tette", + "tirare", + "topa", + "troia", + "trombare", + "uccello", + "vacca", + "vaffanculo", + "vangare", + "venire", + "zinne", + "zio cantante", + "zoccola" +] \ No newline at end of file diff --git a/lib/swearwords/ja.json b/lib/swearwords/ja.json new file mode 100644 index 0000000..cfd30d4 --- /dev/null +++ b/lib/swearwords/ja.json @@ -0,0 +1,188 @@ +[ + "3p", + "g スポット", + "s & m", + "sm", + "sm女王", + "xx", + "アジアのかわいい女の子", + "アスホール", + "アナリングス", + "アナル", + "いたずら", + "イラマチオ", + "ウェブカメラ", + "エクスタシー", + "エスコート", + "エッチ", + "エロティズム", + "エロティック", + "オーガズム", + "オカマ", + "おしっこ", + "おしり", + "オシリ", + "おしりのあな", + "おっぱい", + "オッパイ", + "オナニー", + "オマンコ", + "おもらし", + "お尻", + "カーマスートラ", + "カント", + "クリトリス", + "グループ・セックス", + "グロ", + "クンニリングス", + "ゲイ・セックス", + "ゲイの男性", + "ゲイボーイ", + "ゴールデンシャワー", + "コカイン", + "ゴックン", + "サディズム", + "しばり", + "スウィンガー", + "スカートの中", + "スカトロ", + "ストラップオン", + "ストリップ劇場", + "スラット", + "スリット", + "セクシーな", + "セクシーな 10 代", + "セックス", + "ソドミー", + "ちんこ", + "ディープ・スロート", + "ディック", + "ディルド", + "デートレイプ", + "デブ", + "テレフォンセックス", + "ドッグスタイル", + "トップレス", + "なめ", + "ニガー", + "ヌード", + "ネオ・ナチ", + "ハードコア", + "パイパン", + "バイブレーター", + "バック・スタイル", + "パンティー", + "ビッチ", + "ファック", + "ファンタジー", + "フィスト", + "フェティッシュ", + "フェラチオ", + "ふたなり", + "ぶっかけ", + "フック", + "プリンス アルバート ピアス", + "プレイボーイ", + "ベアバック", + "ペニス", + "ペニスバンド", + "ボーイズラブ", + "ボールギャグ", + "ボールを蹴る", + "ぽっちゃり", + "ホモ", + "ポルノ", + "ポルノグラフィー", + "ボンテージ", + "マザー・ファッカー", + "マスターベーション", + "まんこ", + "やおい", + "やりまん", + "ユダヤ人", + "ラティーナ", + "ラバー", + "ランジェリー", + "レイプ", + "レズビアン", + "ローター", + "ロリータ", + "淫乱", + "陰毛", + "革抑制", + "騎上位", + "巨根", + "巨乳", + "強姦犯", + "玉なめ", + "玉舐め", + "緊縛", + "近親相姦", + "嫌い", + "後背位", + "合意の性交", + "拷問", + "黒人", + "殺し方", + "殺人事件", + "殺人方法", + "支配", + "児童性虐待", + "自己愛性", + "射精", + "手コキ", + "獣姦", + "女の子", + "女王様", + "女子高生", + "女装", + "新しいポルノ", + "人妻", + "人種", + "性交", + "正常位", + "生殖器", + "精液", + "挿入", + "足フェチ", + "足を広げる", + "大陰唇", + "脱衣", + "茶色のシャワー", + "中出し", + "潮吹き女", + "潮吹き男性", + "直腸", + "剃毛", + "貞操帯", + "奴隷", + "二穴", + "乳首", + "尿道プレイ", + "覗き", + "売春婦", + "縛り", + "噴出", + "糞", + "糞尿愛好症", + "糞便", + "平手打ち", + "変態", + "勃起する", + "夢精", + "毛深い", + "誘惑", + "幼児", + "幼児性愛者", + "裸", + "裸の女性", + "乱交", + "両性", + "両性具有", + "両刀", + "輪姦", + "卍", + "宦官", + "肛門", + "膣" +] \ No newline at end of file diff --git a/lib/swearwords/ko.json b/lib/swearwords/ko.json new file mode 100644 index 0000000..0f2ec82 --- /dev/null +++ b/lib/swearwords/ko.json @@ -0,0 +1,74 @@ +[ + "강간", + "개새끼", + "개자식", + "개좆", + "개차반", + "거유", + "계집년", + "고자", + "근친", + "노모", + "니기미", + "뒤질래", + "딸딸이", + "때씹", + "또라이", + "뙤놈", + "로리타", + "망가", + "몰카", + "미친", + "미친새끼", + "바바리맨", + "변태", + "병신", + "보지", + "불알", + "빠구리", + "사까시", + "섹스", + "스와핑", + "쌍놈", + "씨발", + "씨발놈", + "씨팔", + "씹", + "씹물", + "씹빨", + "씹새끼", + "씹알", + "씹창", + "씹팔", + "암캐", + "애자", + "야동", + "야사", + "야애니", + "엄창", + "에로", + "염병", + "옘병", + "유모", + "육갑", + "은꼴", + "자위", + "자지", + "잡년", + "종간나", + "좆", + "좆만", + "죽일년", + "쥐좆", + "직촬", + "짱깨", + "쪽바리", + "창녀", + "포르노", + "하드코어", + "호로", + "화냥년", + "후레아들", + "후장", + "희쭈그리" +] \ No newline at end of file diff --git a/lib/swearwords/nl.json b/lib/swearwords/nl.json new file mode 100644 index 0000000..b58dfa9 --- /dev/null +++ b/lib/swearwords/nl.json @@ -0,0 +1,193 @@ +[ + "aardappels afgieteng", + "achter het raam zitten", + "afberen", + "aflebberen", + "afrossen", + "afrukken", + "aftrekken", + "afwerkplaats", + "afzeiken", + "afzuigen", + "anderhalve man en een paardekop", + "anita", + "asbak", + "aso", + "bagger schijten", + "balen", + "bedonderen", + "befborstelg", + "beffen", + "bekken", + "belazeren", + "besodemieterd zijn", + "besodemieteren", + "beurt", + "boemelen", + "boerelul", + "boerenpummelg", + "bokkelul", + "botergeil", + "broekhoesten", + "brugpieperg", + "buffelen", + "buiten de pot piesen", + "da's kloten van de bok", + "de ballen", + "de hoer spelen", + "de hond uitlaten", + "de koffer induiken", + "delg", + "de pijp aan maarten geven", + "de pijp uitgaan", + "dombo", + "draaikontg", + "driehoog achter wonen", + "drolg", + "drooggeiler", + "droogkloot", + "een beurt geven", + "een nummertje maken", + "een wip maken", + "eikel", + "engerd", + "flamoes", + "flikken", + "flikker", + "gadverdamme", + "galbak", + "gat", + "gedoogzone", + "geilneef", + "gesodemieter", + "godverdomme", + "graftak", + "gras maaien", + "gratenkutg", + "greppeldel", + "griet", + "hoempert", + "hoer", + "hoerenbuurt", + "hoerenloper", + "hoerig", + "hol", + "hufter", + "huisdealer", + "johny", + "kanen", + "kettingzeugg", + "klaarkomen", + "klerebeer", + "klojo", + "klooien", + "klootjesvolk", + "klootoog", + "klootzak", + "kloten", + "knor", + "kontg", + "kontneuken", + "krentekakker", + "kut", + "kuttelikkertje", + "kwakkieg", + "liefdesgrot", + "lul", + "lul-de-behanger", + "lulhannes", + "lummel", + "mafketel", + "matennaaierg", + "matje", + "mof", + "mutsg", + "naaien", + "naakt", + "neuken", + "neukstier", + "nicht", + "oetlul", + "opgeilen", + "opkankeren", + "oprotten", + "opsodemieteren", + "op z'n hondjes", + "op z'n sodemieter geven", + "opzouten", + "ouwehoer", + "ouwehoeren", + "ouwe rukker", + "paal", + "paardelul", + "palen", + "penozeg", + "piesen", + "pijpbekkieg", + "pijpen", + "pik", + "pleurislaaier", + "poep", + "poepen", + "poot", + "portiekslet", + "pot", + "potverdorie", + "publiciteitsgeil", + "raaskallen", + "reet", + "reetridder", + "reet trappen, voor zijn", + "remsporeng", + "reutelen", + "rothoer", + "rotzak", + "rukhond", + "rukken", + "schatje", + "schijt", + "schijten", + "schoft", + "schuinsmarcheerder", + "shit", + "slempen", + "sletg", + "sletterig", + "slik mijn zaad", + "snolg", + "spuiten", + "standje", + "standje-69g", + "stoephoer", + "stootje", + "strontg", + "sufferdg", + "tapijtnek", + "teefg", + "temeier", + "teringlijer", + "toeter", + "tongzoeng", + "triootjeg", + "trottoir prostituée", + "trottoirteef", + "vergallen", + "verkloten", + "verneuken", + "viespeuk", + "vingeren", + "vleesroos", + "voor jan lul", + "voor jan-met-de-korte-achternaam", + "watje", + "welzijnsmafia", + "wijf", + "wippen", + "wuftje", + "zaadje", + "zakkenwasser", + "zeiken", + "zeiker", + "zuigen", + "zuiplap" +] \ No newline at end of file diff --git a/lib/swearwords/no.json b/lib/swearwords/no.json new file mode 100644 index 0000000..f1a44e9 --- /dev/null +++ b/lib/swearwords/no.json @@ -0,0 +1,15 @@ +[ + "drittsekk", + "faen i helvete", + "fitte", + "jævla", + "kuk", + "kukene", + "kuker", + "nigger", + "pikk", + "sotrør", + "ståpikk", + "ståpikkene", + "ståpikker" +] \ No newline at end of file diff --git a/lib/swearwords/pl.json b/lib/swearwords/pl.json new file mode 100644 index 0000000..8078048 --- /dev/null +++ b/lib/swearwords/pl.json @@ -0,0 +1,55 @@ +[ + "burdel", + "burdelmama", + "chuj", + "chujnia", + "ciota", + "cipa", + "cyc", + "debil", + "dmuchać", + "do kurwy nędzy", + "dupa", + "dupek", + "duperele", + "dziwka", + "fiut", + "gówno", + "gówno prawda", + "huj", + "jajco", + "jajeczko", + "jajko", + "jajo", + "ja pierdolę", + "jebać", + "jebany", + "kurwa", + "kurwy", + "kutafon", + "kutas", + "lizać pałę", + "obciągać chuja", + "obciągać fiuta", + "obciągać loda", + "pieprzyć", + "pierdolec", + "pierdolić", + "pierdolnięty", + "pierdoła", + "pierdzieć", + "pizda", + "pojeb", + "popierdolony", + "robic loda", + "robić loda", + "ruchać", + "rzygać", + "skurwysyn", + "sraczka", + "srać", + "suka", + "syf", + "wkurwiać", + "zajebisty" +] \ No newline at end of file diff --git a/lib/swearwords/pt.json b/lib/swearwords/pt.json new file mode 100644 index 0000000..64d8137 --- /dev/null +++ b/lib/swearwords/pt.json @@ -0,0 +1,270 @@ +[ + "aborto", + "amador", + "anus", + "ânus", + "aranha", + "ariano", + "baba-ovo", + "babaca", + "babaovo", + "bacura", + "bagos", + "baitola", + "balalao", + "bastardo", + "bebum", + "besta", + "bicha", + "bisca", + "biscate", + "bissexual", + "bixa", + "boazuda", + "boceta", + "boco", + "bocó", + "boiola", + "bolagato", + "boob", + "bosseta", + "bosta", + "bostana", + "braulio de borracha", + "brioco", + "bronha", + "buca", + "buceta", + "bumbum", + "bunda", + "bunduda", + "burra", + "burro", + "busseta", + "cabrao", + "caceta", + "cacete", + "caga", + "cagado", + "cagalhao", + "cagalhão", + "cagao", + "cagar", + "cagona", + "camisinha", + "canalha", + "caralho", + "casseta", + "cassete", + "cerveja", + "checheca", + "chereca", + "chibumba", + "chibumbo", + "chifruda", + "chifrudo", + "chochota", + "chota", + "chupar", + "clitoris", + "clitóris", + "cocaína", + "cocô", + "colhoes", + "comer", + "cona", + "consolo", + "corna", + "corno", + "cornuda", + "cornudo", + "cretina", + "cretino", + "cu", + "cuzao", + "cuzuda", + "cuzudo", + "cuzão", + "cú", + "dar o rabo", + "debil", + "debiloide", + "defunto", + "demonio", + "demônio", + "doida", + "doido", + "dum raio", + "débil", + "escrota", + "escroto", + "esporra", + "estupido", + "estúpido", + "fecal", + "fedida", + "fedido", + "fedorenta", + "fedorento", + "feia", + "feio", + "feiosa", + "feioso", + "feioza", + "feiozo", + "filho da puta", + "foda", + "foda-se", + "fodace", + "fodao", + "fodasse", + "fode", + "foder", + "fodida", + "fodido", + "fodão", + "frango assado", + "gaiata", + "gaiato", + "gozar", + "grelho", + "grelo", + "heroína", + "heterosexual", + "homem gay", + "idiota", + "imbecil", + "inferno", + "iscrota", + "iscroto", + "ladra", + "ladrao", + "ladrona", + "ladrão", + "lalau", + "leprosa", + "leproso", + "lesbico", + "lolita", + "lésbica", + "lésbico", + "machao", + "machona", + "machorra", + "machão", + "mama", + "meleca", + "merda", + "mija", + "mijada", + "mijado", + "mijar", + "mijo", + "mocrea", + "mocreia", + "mocréa", + "mocréia", + "naba", + "otaria", + "otario", + "otária", + "otário", + "paneleiro", + "paspalha", + "paspalhao", + "paspalho", + "paspalhona", + "paspalhão", + "passar um cheque", + "pau", + "peidar", + "peido", + "peidorreira", + "peidorreiro", + "pemba", + "pepeca", + "perereca", + "pica", + "pilantra", + "pinto", + "piroca", + "pirocao", + "pirocão", + "piru", + "porra", + "precheca", + "prostituta", + "prostituto", + "punheta", + "punhetao", + "punheteira", + "punheteiro", + "punhetão", + "puta", + "puta que pariu", + "puta que te pariu", + "puto", + "puxa-saco", + "puxasaco", + "pênis", + "queca", + "rabuda", + "rabudao", + "rabudo", + "rabudona", + "rabudão", + "ramela", + "ramelona", + "ramelão", + "ridicula", + "ridiculo", + "ridícula", + "ridículo", + "rola", + "rolas", + "rolona", + "sacanagem", + "saco", + "safada", + "safado", + "siririca", + "tarada", + "tarado", + "testuda", + "testudao", + "testudo", + "testudona", + "testudão", + "tesuda", + "tesudo", + "tezuda", + "tezudo", + "torneira", + "transar", + "trolha", + "trolxa", + "trouxa", + "troxa", + "vagabunda", + "vagabundo", + "vai tomar no cu", + "vai-te foder", + "veadao", + "viado", + "viadão", + "viada", + "viadao", + "viadinha", + "viadinho", + "viadona", + "vibrador", + "xana", + "xaninha", + "xavasca", + "xerereca", + "xibiu", + "xibumba", + "xochota", + "xota", + "xoxota" +] \ No newline at end of file diff --git a/lib/swearwords/ru.json b/lib/swearwords/ru.json new file mode 100644 index 0000000..172deda --- /dev/null +++ b/lib/swearwords/ru.json @@ -0,0 +1,154 @@ +[ + "bychara", + "byk", + "chernozhopyi", + "dolboy'eb", + "ebalnik", + "ebalo", + "ebalom sch'elkat", + "gol", + "mudack", + "opizdenet", + "osto'eblo", + "ostokhuitel'no", + "ot'ebis", + "otmudohat", + "otpizdit", + "otsosi", + "padlo", + "pedik", + "perdet", + "petuh", + "pidar gnoinyj", + "pizda", + "pizdato", + "pizdatyi", + "piz'det", + "pizdetc", + "pizdoi nakryt'sja", + "pizd'uk", + "piz`dyulina", + "podi ku'evo", + "poeben", + "po'imat' na konchik", + "po'iti posrat", + "po khuy", + "poluchit pizdy", + "pososi moyu konfetku", + "prissat", + "proebat", + "promudobl'adsksya pizdopro'ebina", + "propezdoloch", + "prosrat", + "raspeezdeyi", + "raspizdatyi", + "raz'yebuy", + "raz'yoba", + "s'ebat'sya", + "shalava", + "styervo", + "sukin syn", + "svodit posrat", + "svoloch", + "trakhat'sya", + "trimandoblydskiy pizdoproyob", + "ubl'yudok", + "uboy", + "u'ebitsche", + "vafl'a", + "vafli lovit", + "v pizdu", + "vyperdysh", + "vzdrochennyi", + "yeb vas", + "za'ebat", + "zaebis", + "zalupa", + "zalupat", + "zasranetc", + "zassat", + "zlo'ebuchy", + "бардак", + "бздёнок", + "блядки", + "блядовать", + "блядство", + "блядь", + "бугор", + "во пизду", + "встать раком", + "выёбываться", + "гандон", + "говно", + "говнюк", + "голый", + "дать пизды", + "дерьмо", + "дрочить", + "другой дразнится", + "ёбарь", + "ебать", + "ебать-копать", + "ебло", + "ебнуть", + "ёб твою мать", + "жопа", + "жополиз", + "играть на кожаной флейте", + "измудохать", + "каждый дрочит как он хочет", + "какая разница", + "как два пальца обоссать", + "курите мою трубку", + "лысого в кулаке гонять", + "малофя", + "манда", + "мандавошка", + "мент", + "муда", + "мудило", + "мудозмон", + "наебать", + "наебениться", + "наебнуться", + "на фиг", + "на хуй", + "на хую вертеть", + "на хуя", + "нахуячиться", + "невебенный", + "не ебет", + "ни за хуй собачу", + "ни хуя", + "обнаженный", + "обоссаться можно", + "один ебётся", + "опесдол", + "офигеть", + "охуеть", + "охуйтельно", + "половое сношение", + "секс", + "сиски", + "спиздить", + "срать", + "ссать", + "траxать", + "ты мне ваньку не валяй", + "фига", + "хапать", + "хер с ней", + "хер с ним", + "хохол", + "хрен", + "хуёво", + "хуёвый", + "хуем груши околачивать", + "хуеплет", + "хуило", + "хуиней страдать", + "хуиня", + "хуй", + "хуйнуть", + "хуй пинать" +] \ No newline at end of file diff --git a/lib/swearwords/sv.json b/lib/swearwords/sv.json new file mode 100644 index 0000000..e8b9555 --- /dev/null +++ b/lib/swearwords/sv.json @@ -0,0 +1,45 @@ +[ + "arsle", + "brutta", + "discofitta", + "dra åt helvete", + "fan", + "fitta", + "fittig", + "för helvete", + "helvete", + "hård", + "jävlar", + "knulla", + "kuk", + "kuksås", + "kötthuvud", + "köttnacke", + "moona", + "moonade", + "moonar", + "moonat", + "mutta", + "nigger", + "neger", + "olla", + "pippa", + "pitt", + "prutt", + "pök", + "runka", + "röv", + "rövhål", + "rövknulla", + "satan", + "skita", + "skit ner dig", + "skäggbiff", + "snedfitta", + "snefitta", + "stake", + "subba", + "sås", + "sätta på", + "tusan" +] \ No newline at end of file diff --git a/lib/swearwords/th.json b/lib/swearwords/th.json new file mode 100644 index 0000000..d6ee348 --- /dev/null +++ b/lib/swearwords/th.json @@ -0,0 +1,33 @@ +[ + "กระดอ", + "กระเด้า", + "กระหรี่", + "กะปิ", + "กู", + "ขี้", + "ควย", + "จิ๋ม", + "จู๋", + "เจ๊ก", + "เจี๊ยว", + "ดอกทอง", + "ตอแหล", + "ตูด", + "น้ําแตก", + "มึง", + "แม่ง", + "เย็ด", + "รูตูด", + "ล้างตู้เย็น", + "ส้นตีน", + "สัด", + "เสือก", + "หญิงชาติชั่ว", + "หลั่ง", + "ห่า", + "หํา", + "หี", + "เหี้ย", + "อมนกเขา", + "ไอ้ควาย" +] \ No newline at end of file diff --git a/lib/swearwords/tlh.json b/lib/swearwords/tlh.json new file mode 100644 index 0000000..317224a --- /dev/null +++ b/lib/swearwords/tlh.json @@ -0,0 +1,5 @@ +[ + "ghuy'cha'", + "QI'yaH", + "Qu'vatlh" +] \ No newline at end of file diff --git a/lib/swearwords/tr.json b/lib/swearwords/tr.json new file mode 100644 index 0000000..47c2385 --- /dev/null +++ b/lib/swearwords/tr.json @@ -0,0 +1,144 @@ +[ + "am", + "amcığa", + "amcığı", + "amcığın", + "amcık", + "amcıklar", + "amcıklara", + "amcıklarda", + "amcıklardan", + "amcıkları", + "amcıkların", + "amcıkta", + "amcıktan", + "amı", + "amlar", + "çingene", + "Çingenede", + "Çingeneden", + "Çingeneler", + "Çingenelerde", + "Çingenelerden", + "Çingenelere", + "Çingeneleri", + "Çingenelerin", + "Çingenenin", + "Çingeneye", + "Çingeneyi", + "göt", + "göte", + "götler", + "götlerde", + "götlerden", + "götlere", + "götleri", + "götlerin", + "götte", + "götten", + "götü", + "götün", + "götveren", + "götverende", + "götverenden", + "götverene", + "götvereni", + "götverenin", + "götverenler", + "götverenlerde", + "götverenlerden", + "götverenlere", + "götverenleri", + "götverenlerin", + "kaltağa", + "kaltağı", + "kaltağın", + "kaltak", + "kaltaklar", + "kaltaklara", + "kaltaklarda", + "kaltaklardan", + "kaltakları", + "kaltakların", + "kaltakta", + "kaltaktan", + "orospu", + "orospuda", + "orospudan", + "orospular", + "orospulara", + "orospularda", + "orospulardan", + "orospuları", + "orospuların", + "orospunun", + "orospuya", + "orospuyu", + "otuz birci", + "otuz bircide", + "otuz birciden", + "otuz birciler", + "otuz bircilerde", + "otuz bircilerden", + "otuz bircilere", + "otuz bircileri", + "otuz bircilerin", + "otuz bircinin", + "otuz birciye", + "otuz birciyi", + "saksocu", + "saksocuda", + "saksocudan", + "saksocular", + "saksoculara", + "saksocularda", + "saksoculardan", + "saksocuları", + "saksocuların", + "saksocunun", + "saksocuya", + "saksocuyu", + "sıçmak", + "sik", + "sike", + "siker sikmez", + "siki", + "sikilir sikilmez", + "sikin", + "sikler", + "siklerde", + "siklerden", + "siklere", + "sikleri", + "siklerin", + "sikmek", + "sikmemek", + "sikte", + "sikten", + "siktir", + "siktirir siktirmez", + "taşağa", + "taşağı", + "taşağın", + "taşak", + "taşaklar", + "taşaklara", + "taşaklarda", + "taşaklardan", + "taşakları", + "taşakların", + "taşakta", + "taşaktan", + "yarağa", + "yarağı", + "yarağın", + "yarak", + "yaraklar", + "yaraklara", + "yaraklarda", + "yaraklardan", + "yarakları", + "yarakların", + "yarakta", + "yaraktan" +] \ No newline at end of file diff --git a/lib/swearwords/zh.json b/lib/swearwords/zh.json new file mode 100644 index 0000000..81019c4 --- /dev/null +++ b/lib/swearwords/zh.json @@ -0,0 +1,296 @@ +[ + "13.", + "13点", + "三级片", + "下三烂", + "下贱", + "个老子的", + "九游", + "乳", + "乳交", + "乳头", + "乳房", + "乳波臀浪", + "交配", + "仆街", + "他奶奶", + "他奶奶的", + "他奶娘的", + "他妈", + "他妈ㄉ王八蛋", + "他妈地", + "他妈的", + "他娘", + "他马的", + "你个傻比", + "你他马的", + "你全家", + "你奶奶的", + "你她马的", + "你妈", + "你妈的", + "你娘", + "你娘卡好", + "你娘咧", + "你它妈的", + "你它马的", + "你是鸡", + "你是鸭", + "你马的", + "做爱", + "傻比", + "傻逼", + "册那", + "军妓", + "几八", + "几叭", + "几巴", + "几芭", + "刚度", + "刚瘪三", + "包皮", + "十三点", + "卖B", + "卖比", + "卖淫", + "卵", + "卵子", + "双峰微颤", + "口交", + "口肯", + "叫床", + "吃屎", + "后庭", + "吹箫", + "塞你公", + "塞你娘", + "塞你母", + "塞你爸", + "塞你老师", + "塞你老母", + "处女", + "外阴", + "大卵子", + "大卵泡", + "大鸡巴", + "奶", + "奶奶的熊", + "奶子", + "奸", + "奸你", + "她妈地", + "她妈的", + "她马的", + "妈B", + "妈个B", + "妈个比", + "妈个老比", + "妈妈的", + "妈比", + "妈的", + "妈的B", + "妈逼", + "妓", + "妓女", + "妓院", + "妳她妈的", + "妳妈的", + "妳娘的", + "妳老母的", + "妳马的", + "姘头", + "姣西", + "姦", + "娘个比", + "娘的", + "婊子", + "婊子养的", + "嫖娼", + "嫖客", + "它妈地", + "它妈的", + "密洞", + "射你", + "射精", + "小乳头", + "小卵子", + "小卵泡", + "小瘪三", + "小肉粒", + "小骚比", + "小骚货", + "小鸡巴", + "小鸡鸡", + "屁眼", + "屁股", + "屄", + "屌", + "巨乳", + "干x娘", + "干七八", + "干你", + "干你妈", + "干你娘", + "干你老母", + "干你良", + "干妳妈", + "干妳娘", + "干妳老母", + "干妳马", + "干您娘", + "干机掰", + "干死CS", + "干死GM", + "干死你", + "干死客服", + "幹", + "强奸", + "强奸你", + "性", + "性交", + "性器", + "性无能", + "性爱", + "情色", + "想上你", + "懆您妈", + "懆您娘", + "懒8", + "懒八", + "懒叫", + "懒教", + "成人", + "我操你祖宗十八代", + "扒光", + "打炮", + "打飞机", + "抽插", + "招妓", + "插你", + "插死你", + "撒尿", + "操你", + "操你全家", + "操你奶奶", + "操你妈", + "操你娘", + "操你祖宗", + "操你老妈", + "操你老母", + "操妳", + "操妳全家", + "操妳妈", + "操妳娘", + "操妳祖宗", + "操机掰", + "操比", + "操逼", + "放荡", + "日他娘", + "日你", + "日你妈", + "日你老娘", + "日你老母", + "日批", + "月经", + "机八", + "机巴", + "机机歪歪", + "杂种", + "浪叫", + "淫", + "淫乱", + "淫妇", + "淫棍", + "淫水", + "淫秽", + "淫荡", + "淫西", + "湿透的内裤", + "激情", + "灨你娘", + "烂货", + "烂逼", + "爛", + "狗屁", + "狗日", + "狗狼养的", + "玉杵", + "王八蛋", + "瓜娃子", + "瓜婆娘", + "瓜批", + "瘪三", + "白烂", + "白痴", + "白癡", + "祖宗", + "私服", + "笨蛋", + "精子", + "老二", + "老味", + "老母", + "老瘪三", + "老骚比", + "老骚货", + "肉壁", + "肉棍子", + "肉棒", + "肉缝", + "肏", + "肛交", + "肥西", + "色情", + "花柳", + "荡妇", + "賤", + "贝肉", + "贱B", + "贱人", + "贱货", + "贼你妈", + "赛你老母", + "赛妳阿母", + "赣您娘", + "轮奸", + "迷药", + "逼", + "逼样", + "野鸡", + "阳具", + "阳萎", + "阴唇", + "阴户", + "阴核", + "阴毛", + "阴茎", + "阴道", + "阴部", + "雞巴", + "靠北", + "靠母", + "靠爸", + "靠背", + "靠腰", + "驶你公", + "驶你娘", + "驶你母", + "驶你爸", + "驶你老师", + "驶你老母", + "骚比", + "骚货", + "骚逼", + "鬼公", + "鸡8", + "鸡八", + "鸡叭", + "鸡吧", + "鸡奸", + "鸡巴", + "鸡芭", + "鸡鸡", + "龟儿子", + "龟头" +] \ No newline at end of file diff --git a/lib/util.js b/lib/util.js index 1ff1711..104a01c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -4,34 +4,46 @@ License: http://opensource.org/licenses/MIT The MIT License (MIT) */ var _ = require('underscore'); +var fs = require('fs'); +var Promise = require('bluebird'); +var readFile = Promise.promisify(fs.readFile); function eachRecursive (obj, fn, maxDepth, depth, checked) { - checked = checked || []; + checked = checked || []; - depth = depth || 0; + depth = depth || 0; + if ((maxDepth && depth > maxDepth) || obj in checked) { + return; + } - if ((maxDepth && depth > maxDepth) || obj in checked) { - return; - } + _.each(obj, function (val, key) { + checked.push(obj); - _.each(obj, function (val, key) { - checked.push(obj); + if (_.isObject(val)) { + for (var i in checked) { + if (val == checked[i]) { + return; + } + } - if (_.isObject(val)) { - if (val in checked) { - return; - } + checked.push(val); - checked.push(val); + depth += 1; + eachRecursive(val, fn, maxDepth, depth, checked); + } else { + fn(val, key, obj, depth); + } + }); +} - depth += 1; - eachRecursive(val, fn, depth, checked); - } else { - fn(val, key, obj, depth); - } - }); +function promisiFyReadJsonFile(fileName, options) { + return readFile(fileName, options) + .then(data => { + return JSON.parse(data); + }); } module.exports = { - eachRecursive: eachRecursive + eachRecursive: eachRecursive, + promisiFyReadJsonFile: promisiFyReadJsonFile }; diff --git a/package.json b/package.json index c1738ad..078e747 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,22 @@ { "name": "profanity-util", - "version": "0.0.5", + "version": "1.0.0", "description": "Utility for detection, filtering and replacement / obscuration of forbidden words", "main": "lib/profanity.js", "scripts": { - "test": "mocha test" + "test": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha", + "coveralls": "cat ./coverage/lcov.info | node ./node_modules/.bin/coveralls" }, "author": "Tancredi Trugenberger", "license": "MIT", "dependencies": { - "underscore": "~1.6.0" + "bluebird": "^3.3.5", + "underscore": "^1.8.3" }, "devDependencies": { - "mocha": "~1.20.x", - "should": "~3.3.x" + "coveralls": "^2.11.9", + "istanbul": "^0.4.3", + "mocha": "^2.4.5", + "should": "^8.3.0" } } diff --git a/test/.jshintrc b/test/.jshintrc index 25245d9..f135188 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -5,12 +5,10 @@ "esnext": true, "globalstrict": false, "expr": true, - "indent": 4, + "indent": 2, "quotmark": true, "smarttabs": true, "trailing": true, - "undef": true, - "unused": true, "globals": { "it": true, "describe": true, diff --git a/test/profanity.test.js b/test/profanity.test.js index 2b2237f..2e88974 100644 --- a/test/profanity.test.js +++ b/test/profanity.test.js @@ -4,123 +4,347 @@ License: http://opensource.org/licenses/MIT The MIT License (MIT) */ var should = require('should'), - util = require('./util'), - profanity = require('../lib/profanity'); - -describe('Profanity module', function () { - describe('.validate(target)', function () { - - it('returns null with no swearwords found in string', function () { - should(profanity.check('No swearwords here')).eql([]); + util = require('./util'), + profanity = require('../lib/profanity'), + _ = require('underscore'); + +function callTestCheckFunctions(languages, forbiddenList) { + it('Should return null with no swearwords found in string', () => { + should(profanity.check('No swearwords here', languages, forbiddenList)).eql([]); + }); + + it('Should return array of swearwords found in dirty string', () => { + var results = profanity.check('something damn something something poo something', languages, forbiddenList); + + should(results).eql([ + 'damn', + 'poo' + ]); + }); + + it('Should not target substrings', () => { + var detected = profanity.check('foo ass bar', languages, forbiddenList), + notDetected = profanity.check('foo grass bar', languages, forbiddenList); + + should(detected).have.length(1); + should(notDetected).have.length(0); + }); + + it('Should work equally for objects (Recursively) and arrays', () => { + var results_obj = profanity.check({ + foo: 'something damn', + bar: { test: 'something poo', bar: 'crap woooh' } + }, languages, forbiddenList), + results_arr = profanity.check([ + 'something damn', + ['something poo'], + { foo: [{ bar: 'something crap' }] } + ], languages, forbiddenList); + + should(results_obj).eql([ + 'damn', + 'poo', + 'crap' + ]); + + should(results_arr).eql([ + 'damn', + 'poo', + 'crap' + ]); + }); +} + +describe('Profanity module', () => { + describe('.check(target)', () => { + callTestCheckFunctions(); + }); + + describe('.check(target) when languages="all"', () => { + callTestCheckFunctions('all', null); + }); + + describe('.check(target) for portuguese', () => { + it('Should not get a portuguese dirty word when there is no language specifided (default is english)', () => { + var notDetected = profanity.check('viados não gostam de pepeca', null); + + should(notDetected).have.length(0); + }); + + it('Should get a dirty word and not get substrings', () => { + var detected = profanity.check('viado não gosta de pepeca', 'pt'); + var notDetected = profanity.check('viados não gosta de pepecas', 'pt'); + + detected.should.eql(['viado', 'pepeca']); + notDetected.should.eql([]); + }); + + it('Should work equally for objects (Recursively) and arrays', () => { + var results_obj = profanity.check({ foo: 'something perereca', bar: { test: 'something punheta', bar: 'paspalhão woooh' } }, 'pt'), + results_arr = profanity.check(['something porra', ['something precheca'], { foo: [{ bar: 'something puta' }] }], 'pt'); + + should(results_obj).eql([ + 'perereca', + 'punheta', + 'paspalhão' + ]); + + should(results_arr).eql([ + 'porra', + 'precheca', + 'puta' + ]); + }); + }); + + describe('.check(target) for multiple languages', () => { + it('Should get a dirty word and not get substrings', () => { + var detected = profanity.check('viado não gosta de pepeca fucker bocchinara reudig', ['pt', 'it', 'de', 'en']); + var notDetected = profanity.check('viados não gosta de pepecas fuckersras, bocchinarasws reudigs', ['pt', 'it', 'de', 'en']); + + detected.should.eql(['viado', 'pepeca', 'fucker', 'bocchinara', 'reudig']); + notDetected.should.eql([]); + }); + + it('Should work equally for objects (Recursively) and arrays', () => { + var results_obj = profanity.check({ foo: 'something perereca fucker ', bar: { test: 'something punheta bocchinara', bar: 'paspalhão reudig woooh' } }, ['pt', 'it', 'de', 'en']), + results_arr = profanity.check(['something porra fucker', ['something precheca bocchinara '], { foo: [{ bar: 'something puta reudig' }] }], 'all'); + + should(results_obj).eql([ + 'perereca', + 'fucker', + 'punheta', + 'bocchinara', + 'paspalhão', + 'reudig' + ]); + + should(results_arr).eql([ + 'porra', + 'fucker', + 'precheca', + 'bocchinara', + 'puta', + 'reudig' + ]); + }); + }); + + describe('.checkAsync(target)', () => { + it('Should return null with no swearwords found in string', () => { + return profanity.checkAsync('No swearwords here') + .then(results => { + should(results).eql([]); }); + }); - it('returns array of swearwords found in dirty string', function () { - var results = profanity.check('something damn something something poo something'); + it('Should return array of swearwords found in dirty string', () => { + return profanity.checkAsync('something damn something something poo something') + .then(results => { + should(results).eql([ + 'damn', + 'poo' + ]); + }); + }); - should(results).eql([ - 'damn', - 'poo' - ]); + it('Should work when passing my own forbidden list', () => { + return profanity.checkAsync('something damn something something poo something', 'en', ['damn', 'poo']) + .then(results => { + should(results).eql([ + 'damn', + 'poo' + ]); }); + }); - it('doesn\'t target substrings', function () { - var detected = profanity.check('foo ass bar'), - notDetected = profanity.check('foo grass bar'); + it('Should not target substrings', () => { + Promise.all([profanity.checkAsync('foo ass bar'), profanity.checkAsync('foo grass bar')]) + .then(results => { + var detected = results[0]; + var notDetected = results[1]; - should(detected).have.length(1); - should(notDetected).have.length(0); + detected.should.have.length(1); + notDetected.should.have.length(0); }); + }); - it('works equally for objects (Recursively) and arrays', function (done) { - var results_obj = profanity.check({ - foo: 'something damn', - bar: { test: 'something poo', bar: 'crap woooh' } - }), - results_arr = profanity.check([ - 'something damn', - [ 'something poo' ], - { foo: [ { bar: 'something crap' } ] } - ]); - - should(results_obj).eql([ - 'damn', - 'poo', - 'crap' - ]); - - should(results_arr).eql([ - 'damn', - 'poo', - 'crap' - ]); - - done(); + it('Should work equally for objects (Recursively) and arrays', () => { + var firstTarget = { foo: 'something damn', bar: { test: 'something poo', bar: 'crap woooh' } }; + var secondTarget = { foo: 'something damn', bar: { test: 'something poo', bar: 'crap woooh' } }; + var thirdTarget = ['something damn', ['something poo'], { foo: [{ bar: 'something crap' }] }]; + Promise.all([profanity.checkAsync(firstTarget), profanity.checkAsync(secondTarget), profanity.checkAsync(thirdTarget)]) + .then(results => { + results.should.have.length(3); + _.each(results, result => { + result.should.eql(['damn', 'poo', 'crap']); + }); }); + }); + it('Should jump to catch when passing language that is not supported by the tool', () => { + profanity.checkAsync('Anything', ['HUE']) + .catch(err => { + err.code.should.eql('ENOENT'); + }); }); - describe('.purify(target)', function () { + }); - it('works in obscure (default) mode on a simple string', function (done) { - var result = profanity.purify('boob damn something poo'); - result[0].should.equal('b**b d**n something p*o'); - result[1].should.eql([ 'boob', 'damn', 'poo' ]); + describe('.purify(target)', () => { + it('Should work in obscure (default) mode on a simple string', () => { + var result = profanity.purify('boob damn something poo'); + result[0].should.equal('b**b d**n something p*o'); + result[1].should.eql(['boob', 'damn', 'poo']); + }); - done(); - }); + it('Should work when passing my own forbidden list', () => { + var result = profanity.purify('boob damn something pota', { forbiddenList: ['boob', 'damn', 'pota'] }); + + result[0].should.equal('b**b d**n something p**a'); + result[1].should.eql(['boob', 'damn', 'pota']); + }); + + it('Should work in obscure (default) mode recursively with objects, with infinite recursion and maxRecursionDepth', () => { + var testObj = { + bar: { foo: 'something boob', bar: { foo: 'test poo', bler: { foo: 'will not enter here' } } }, + test: 'something damn' + }; + testObj.crazy = testObj; + + var result = profanity.purify(testObj, { maxRecursionDepth: 1 }); - it('works in obscure (default) mode recursively with objects', function (done) { - var result = profanity.purify({ - bar: { foo: 'something boob', bar: { foo: 'test poo' } }, - test: 'something damn' - }); + result[0].should.have.keys('bar', 'test', 'crazy'); + result[0].bar.should.have.keys('foo', 'bar'); + result[0].bar.foo.should.equal('something b**b'); + result[0].bar.bar.should.have.keys('foo', 'bler'); + result[0].bar.bar.foo.should.equal('test p*o'); + result[0].bar.foo.should.equal('something b**b'); + result[0].test.should.equal('something d**n'); - result[0].should.have.keys('bar', 'test'); - result[0].bar.should.have.keys('foo', 'bar'); - result[0].bar.foo.should.equal('something b**b'); - result[0].bar.bar.should.have.keys('foo'); - result[0].bar.bar.foo.should.equal('test p*o'); - result[0].bar.foo.should.equal('something b**b'); - result[0].test.should.equal('something d**n'); + result[1].should.eql(['boob', 'poo', 'damn']); + }); + + it('Should work in replace mode on a simple string', () => { + var result = profanity.purify('boob damn something poo', { + replace: true + }); - result[1].should.eql([ 'boob', 'poo', 'damn' ]); + util.testPurified(result[0], '[ placeholder ] [ placeholder ] something [ placeholder ]'); + result[1].should.eql(['boob', 'damn', 'poo']); + }); - done(); + it('Should work in replace mode recursively with objects', () => { + var result = profanity.purify({ + bar: { foo: 'something boob', bar: { foo: 'test poo' } }, + test: 'something damn' + }, { + replace: true }); - it('works in replace mode on a simple string', function (done) { - var result = profanity.purify('boob damn something poo', { - replace: true - }); + result[0].should.have.keys('bar', 'test'); + result[0].bar.should.have.keys('foo', 'bar'); + util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); + result[0].bar.bar.should.have.keys('foo'); + util.testPurified(result[0].bar.bar.foo, 'test [ placeholder ]'); + util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); + util.testPurified(result[0].test, 'something [ placeholder ]'); + + result[1].should.eql(['boob', 'poo', 'damn']); + }); + }); - util.testPurified(result[0], '[ placeholder ] [ placeholder ] something [ placeholder ]'); - result[1].should.eql([ 'boob', 'damn', 'poo' ]); + describe('.purifyAsync(target)', () => { + it('Should work in obscure (default) mode on a simple string', () => { + return profanity.purifyAsync('boob damn something poo') + .then(result => { + result[0].should.equal('b**b d**n something p*o'); + result[1].should.eql(['boob', 'damn', 'poo']); + }); + }); + it('Should work in obscure (default) mode recursively with objects', () => { + var objToCheck = { + bar: { foo: 'something boob', bar: { foo: 'test poo' } }, + test: 'something damn' + }; + return profanity.purifyAsync(objToCheck) + .then(result => { + result[0].should.have.keys('bar', 'test'); + result[0].bar.should.have.keys('foo', 'bar'); + result[0].bar.foo.should.equal('something b**b'); + result[0].bar.bar.should.have.keys('foo'); + result[0].bar.bar.foo.should.equal('test p*o'); + result[0].bar.foo.should.equal('something b**b'); + result[0].test.should.equal('something d**n'); - done(); + result[1].should.eql(['boob', 'poo', 'damn']); }); + }); - it('works in replace mode recursively with objects', function (done) { - var result = profanity.purify({ - bar: { foo: 'something boob', bar: { foo: 'test poo' } }, - test: 'something damn' - }, { - replace: true - }); - - result[0].should.have.keys('bar', 'test'); - result[0].bar.should.have.keys('foo', 'bar'); - util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); - result[0].bar.bar.should.have.keys('foo'); - util.testPurified(result[0].bar.bar.foo, 'test [ placeholder ]'); - util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); - util.testPurified(result[0].test, 'something [ placeholder ]'); - - result[1].should.eql([ 'boob', 'poo', 'damn' ]); - - done(); + it('Should work in replace mode on a simple string', () => { + return profanity.purifyAsync('boob damn something poo', { replace: true }) + .then(result => { + util.testPurified(result[0], '[ placeholder ] [ placeholder ] something [ placeholder ]'); + result[1].should.eql(['boob', 'damn', 'poo']); }); + }); + + it('Should work in replace mode recursively with objects', () => { + var objToCheck = { + bar: { foo: 'something boob', bar: { foo: 'test poo' } }, + test: 'something damn' + }; + + return profanity.purifyAsync(objToCheck, { replace: true }) + .then(result => { + result[0].should.have.keys('bar', 'test'); + result[0].bar.should.have.keys('foo', 'bar'); + util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); + result[0].bar.bar.should.have.keys('foo'); + util.testPurified(result[0].bar.bar.foo, 'test [ placeholder ]'); + util.testPurified(result[0].bar.foo, 'something [ placeholder ]'); + util.testPurified(result[0].test, 'something [ placeholder ]'); + + result[1].should.eql(['boob', 'poo', 'damn']); + + + }); + }); + it('Should jump to catch when passing language that is not supported by the tool', () => { + return profanity.purifyAsync('Anything', { languages: ['HUE'] }) + .catch(err => { + err.code.should.eql('ENOENT'); + }); + }); + + it('Should work when passing a custom replacements list', () => { + var replacementsList = ['foo', 'bar', 'baz']; + return profanity.purifyAsync('Something poo something fuck', { replace: true, replacementsList}) + .then(result => { + util.testPurified(result[0], 'Something [ placeholder ] something [ placeholder ]', '(foo|bar|baz)'); + result[1].should.eql(['poo', 'fuck']); + }); + }); + + it('Should use the default replacement list when passing an empty replacements list', () => { + var replacementsList = []; + return profanity.purifyAsync('Something poo something fuck', { replace: true, replacementsList}) + .then(result => { + util.testPurified(result[0], 'Something [ placeholder ] something [ placeholder ]'); + result[1].should.eql(['poo', 'fuck']); + }); + }); + + it('Should use the default replacement list when passing a replacement list that is not an array', () => { + var replacementsList = 'dasdasd'; + return profanity.purifyAsync('Something poo something fuck', { replace: true, replacementsList}) + .then(result => { + util.testPurified(result[0], 'Something [ placeholder ] something [ placeholder ]'); + result[1].should.eql(['poo', 'fuck']); + }); }); + }); });