mirror of
https://github.com/PretendoNetwork/website.git
synced 2026-03-21 17:24:28 -05:00
fix: fix blogpost and terms name checks
This commit is contained in:
parent
d5a05e0502
commit
b342d7c9c5
|
|
@ -69,6 +69,12 @@ router.get('/:slug', async (request, response, next) => {
|
|||
// Get the name of the post from the URL
|
||||
const postName = request.params.slug;
|
||||
|
||||
if (!/^[0-9-]+$/.test(postName)) {
|
||||
logger.error(`Invalid blog post name name ${postName}`);
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the markdown file corresponding to the post
|
||||
let rawPost;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ router.get('/:slug', async (request, response, next) => {
|
|||
|
||||
const termName = request.params.slug;
|
||||
|
||||
if (!/^[a-z]+$/.test(termName)) {
|
||||
logger.error(`Invalid term name ${termName}`);
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
let rawTerm;
|
||||
try {
|
||||
rawTerm = await fs.readFile(path.join('terms', `${termName}.md`), 'utf-8');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user