Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reserved.ts to include hexpeak and permutations of slurs #1326

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 48 additions & 32 deletions packages/identifier/src/reserved.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,91 +1047,107 @@ const famousAccounts = [
'zerohora',
]


// naive, incomplete list of slurs and unacceptable words
const slurs = [
const slurs_template = [
'bluegum',
'chink',
'chinks',
'coolie',
'coolies',
'coon',
'coons',
'coont',
'golliwog',
'golliwogs',
'gook',
'gooks',
'gyp',
'gyps',
'half-breed',
'halfbreed',
'half-breeds',
'halfbreeds',
'heeb',
'heebs',
'hitler',
'jeet',
'kaffer',
'kaffers',
'kaffir',
'kaffirs',
'kaffre',
'kaffres',
'kafir',
'kafirs',
'kike',
'kikes',
'kkk',
'klukluxklan',
'muzzie',
'n1gga',
'n1gger',
'nazi ',
'nazi',
'negorid',
'negress',
'negresses',
'nig-nog',
'nig',
'nigg3r',
'nigg4h',
'nigga',
'niggah',
'niggas',
'niggaz',
'nigger',
'niggerachi',
'niggerette',
'niggerican',
'niggerino',
'niggeroid',
'niggers',
'nigglet',
'nigguh',
'nigguhs',
'nig-nog',
'nig-nogs',
'nigs',
'pajeet',
'paki',
'pakis',
'pedophile',
'pickaninnie',
'pickaninnies',
'pickaninny',
'pickaninnys',
'raghead',
'ragheads',
'redskin',
'retard',
'sambo',
'sambos',
'spade',
'spades',
'spic',
'spics',
'squaw',
'squaws',
'wetback',
'wetbacks',
'yid',
'yids',
]

function hexspeak_permutate(words: string[]): string[] {
const hex_dict: { [key: string]: string } = {'a': '4', 'b': '6', 'e': '3', 'g': '9', 'i': '1', 'l': '1', 'o': '0', 's': '5', 't': '7', 'z': '2'};
let hex_words: string[] = [];

for (let word of words) {
let hex_chars: string[][] = [];
for (let char of word) {
if (char in hex_dict) {
hex_chars.push([char, hex_dict[char]]);
} else {
hex_chars.push([char]);
}
}

let permutations: string[][] = cartesian(hex_chars);
for (let item of permutations) {
let hex_word = item.join('');
hex_words.push(hex_word);
hex_words.push(hex_word + 's');
hex_words.push(hex_word + '5');
Comment on lines +1129 to +1130
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to whomever reviews this: this is likely the most important part that really should have been there before.

}
}

return hex_words;
}

function cartesian(arr: any): any {
return arr.reduce((a: any, b: any) => {
return a.map((x: any) => {
return b.map((y: any) => {
return x.concat(y);
})
}).reduce((a: any, b: any) => {
return a.concat(b);
}, [])
}, [[]]);
}

const slurs = hexspeak_permutate(slurs_template);

export const reservedSubdomains: Record<string, boolean> = [
...atpSpecific,
...commonlyReserved,
Expand Down