mirror of
https://github.com/PretendoNetwork/juxtaposition-ui.git
synced 2026-09-13 03:45:30 -05:00
posts: update post body checks and regex
This commit is contained in:
@@ -97,13 +97,17 @@ router.post('/new', async function (req, res, next) {
|
||||
miiFace = 'normal_face.png';
|
||||
break;
|
||||
}
|
||||
let body = req.body.body;
|
||||
if (body) {
|
||||
body = req.body.body.replace(/[^\p{L}\p{P}\d\n\r~$^¨←→↑↓√¦⇒⇔¤¢€£¥™©®+×÷=±∞˘˙¸˛˜°¹²³♭♪¬¯¼½¾♡♥●◆■▲▼☆★♀♂<>]/gu, '');
|
||||
const body = req.body.body;
|
||||
if (body && util.INVALID_POST_BODY_REGEX.test(body)) {
|
||||
// TODO - Log this error
|
||||
return res.sendStatus(422);
|
||||
}
|
||||
if (body.length > 280) {
|
||||
body = body.substring(0,280);
|
||||
|
||||
if (body && body.length > 280) {
|
||||
// TODO - Log this error
|
||||
return res.sendStatus(422);
|
||||
}
|
||||
|
||||
const document = {
|
||||
community_id: conversation.id,
|
||||
screen_name: req.user.mii.name,
|
||||
|
||||
@@ -240,12 +240,15 @@ async function newPost(req, res) {
|
||||
miiFace = 'normal_face.png';
|
||||
break;
|
||||
}
|
||||
let body = req.body.body;
|
||||
if (body) {
|
||||
body = req.body.body.replace(/[^\p{L}\p{P}\d\n\r~$^¨←→↑↓√¦⇒⇔¤¢€£¥™©®+×÷=±∞˘˙¸˛˜°¹²³♭♪¬¯¼½¾♡♥●◆■▲▼☆★♀♂<>]/gu, '');
|
||||
const body = req.body.body;
|
||||
if (body && util.INVALID_POST_BODY_REGEX.test(body)) {
|
||||
// TODO - Log this error
|
||||
return res.sendStatus(422);
|
||||
}
|
||||
if (body.length > 280 && !req.moderator) {
|
||||
body = body.substring(0, 280);
|
||||
|
||||
if (body && body.length > 280) {
|
||||
// TODO - Log this error
|
||||
return res.sendStatus(422);
|
||||
}
|
||||
const document = {
|
||||
title_id: community.title_id[0],
|
||||
|
||||
@@ -74,6 +74,8 @@ function nameCache() {
|
||||
}
|
||||
|
||||
const methods = {
|
||||
// TODO - This doesn't belong here, just hacking it in. Gonna redo this whole server anyway so fuck it
|
||||
INVALID_POST_BODY_REGEX: /[^\p{L}\p{P}\d\n\r$^¨←→↑↓√¦⇒⇔¤¢€£¥™©®+×÷=±∞˘˙¸˛˜°¹²³♭♪¬¯¼½¾♡♥●◆■▲▼☆★♀♂<> ]/gu,
|
||||
create_user: async function(pid, experience, notifications) {
|
||||
const pnid = await this.getUserDataFromPid(pid);
|
||||
if (!pnid) {
|
||||
|
||||
Reference in New Issue
Block a user