mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-18 12:05:28 -04:00
[sec] remove apostrophes from keys
This commit is contained in:
parent
e01d50f464
commit
368e7a83e2
@ -1,7 +1,7 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import SQL from "sql-template-strings";
|
import SQL from "sql-template-strings";
|
||||||
import {ulid} from "ulid";
|
import {ulid} from "ulid";
|
||||||
import {handleErrorAsync} from "../../src/helpers";
|
import {clearKey, handleErrorAsync} from "../../src/helpers";
|
||||||
|
|
||||||
const approve = async (db, id) => {
|
const approve = async (db, id) => {
|
||||||
const { base_id } = await db.get(SQL`SELECT base_id FROM sources WHERE id=${id}`);
|
const { base_id } = await db.get(SQL`SELECT base_id FROM sources WHERE id=${id}`);
|
||||||
@ -84,7 +84,7 @@ router.post('/sources/submit', handleErrorAsync(async (req, res) => {
|
|||||||
${id}, ${global.config.locale}, ${req.body.pronouns.join(';')},
|
${id}, ${global.config.locale}, ${req.body.pronouns.join(';')},
|
||||||
${req.body.type}, ${req.body.author}, ${req.body.title}, ${req.body.extra}, ${req.body.year},
|
${req.body.type}, ${req.body.author}, ${req.body.title}, ${req.body.extra}, ${req.body.year},
|
||||||
${req.body.fragments.join('@').replace(/\n/g, '|')}, ${req.body.comment}, ${req.body.link},
|
${req.body.fragments.join('@').replace(/\n/g, '|')}, ${req.body.comment}, ${req.body.link},
|
||||||
${req.body.key || null}, ${req.body.images || null},
|
${clearKey(req.body.key)}, ${req.body.images || null},
|
||||||
${req.user ? req.user.id : null}, ${req.body.base}
|
${req.user ? req.user.id : null}, ${req.body.base}
|
||||||
)
|
)
|
||||||
`);
|
`);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import SQL from 'sql-template-strings';
|
import SQL from 'sql-template-strings';
|
||||||
import {ulid} from "ulid";
|
import {ulid} from "ulid";
|
||||||
import {isTroll, handleErrorAsync, sortClearedLinkedText} from "../../src/helpers";
|
import {isTroll, handleErrorAsync, sortClearedLinkedText, clearKey} from "../../src/helpers";
|
||||||
import { caches } from "../../src/cache";
|
import { caches } from "../../src/cache";
|
||||||
|
|
||||||
const approve = async (db, id) => {
|
const approve = async (db, id) => {
|
||||||
@ -95,7 +95,7 @@ router.post('/terms/submit', handleErrorAsync(async (req, res) => {
|
|||||||
INSERT INTO terms (id, term, original, key, definition, approved, base_id, locale, author_id, category, flags, images)
|
INSERT INTO terms (id, term, original, key, definition, approved, base_id, locale, author_id, category, flags, images)
|
||||||
VALUES (
|
VALUES (
|
||||||
${id},
|
${id},
|
||||||
${req.body.term.join('|')}, ${req.body.original.join('|')}, ${req.body.key || null}, ${req.body.definition},
|
${req.body.term.join('|')}, ${req.body.original.join('|')}, ${clearKey(req.body.key)}, ${req.body.definition},
|
||||||
0, ${req.body.base}, ${global.config.locale}, ${req.user ? req.user.id : null},
|
0, ${req.body.base}, ${global.config.locale}, ${req.user ? req.user.id : null},
|
||||||
${req.body.categories.join(',')}, ${JSON.stringify(req.body.flags)}, ${req.body.images}
|
${req.body.categories.join(',')}, ${JSON.stringify(req.body.flags)}, ${req.body.images}
|
||||||
)
|
)
|
||||||
|
@ -207,3 +207,8 @@ export const sortClearedLinkedText = (items, key) => {
|
|||||||
items.sort((a, b) => clearLinkedText(a[key].toLowerCase()).localeCompare(clearLinkedText(b[key].toLowerCase())))
|
items.sort((a, b) => clearLinkedText(a[key].toLowerCase()).localeCompare(clearLinkedText(b[key].toLowerCase())))
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const clearKey = (key) => {
|
||||||
|
if (!key) { return null; }
|
||||||
|
return key.replace(/'/g, '_');
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user