jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

32 lines
1.2 KiB

'use strict';
module.exports = (req, res) => {
//combines a bunch of parts of the post (name, subject, message, filenames+phashes)
const fileStrings = res.locals.numFiles ? req.files.file.map(f => `${f.name}|${f.phash || ''}`).join('|') : 0;
const combinedString = [req.body.name, req.body.message, req.body.subject, req.body.email, fileStrings].join('|').toLowerCase();
//"strict" filtering adds a bunch of permutations to also compare filters with;
let strictCombinedString = combinedString;
//diacritics and "zalgo" removed
strictCombinedString += combinedString.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
//zero width spaces removed
strictCombinedString += combinedString.replace(/[\u200B-\u200D\uFEFF]/g, '');
//just a-z, 0-9, . and -
strictCombinedString += combinedString.replace(/[^a-zA-Z0-9.-]+/gm, '');
//urlendoded characters in URLs replaced (todo: remove this if/when the url regex gets updated to no longer match these)
strictCombinedString += combinedString.split(/(%[^%]+)/).map(part => {
try {
return decodeURIComponent(part);
} catch(e) {
return '';
}
}).join('');
return { combinedString, strictCombinedString };
};