refactor: extract escapeRegex and validateTagSlugs server utils

Deduplicate tag validation and regex escaping into shared auto-imported
utils. Add tag validation to wiki patch/batch-tag routes. Remove
duplicate tags field from event schema.
This commit is contained in:
Jennie Robinson Faber 2026-04-09 23:51:56 +01:00
parent f585fabf21
commit a516f172fb
11 changed files with 33 additions and 31 deletions

View file

@ -42,8 +42,7 @@ export default defineEventHandler(async (event) => {
}
if (search) {
// Escape regex metacharacters to prevent ReDoS
const escaped = search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const escaped = escapeRegex(search);
andConditions.push({
$or: [
{ name: { $regex: escaped, $options: "i" } },