fix: fix blogpost and terms name checks

This commit is contained in:
Jonathan Barrow 2025-03-17 18:37:19 -04:00
parent d5a05e0502
commit b342d7c9c5
No known key found for this signature in database
GPG Key ID: 2A7DAA6DED5A77E5
2 changed files with 12 additions and 0 deletions

View File

@ -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 {

View File

@ -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');