mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 01:07:04 +02:00
Validate first and last names before saving them to database. This should prevent security issue with un-sanitized data that ends up in emails. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
20 lines
517 B
TypeScript
20 lines
517 B
TypeScript
/* eslint-disable @typescript-eslint/naming-convention */
|
|
import { registerDecorator } from 'class-validator';
|
|
|
|
export function NoXss() {
|
|
return (object: object, propertyName: string): void => {
|
|
registerDecorator({
|
|
name: 'NoXss',
|
|
target: object.constructor,
|
|
propertyName,
|
|
constraints: [propertyName],
|
|
options: { message: `Malicious ${propertyName}` },
|
|
validator: {
|
|
validate(value: string) {
|
|
return !/(^http|^www)|<(\s*)?(script|a)|(\.[\p{L}\d-]+)/u.test(value);
|
|
},
|
|
},
|
|
});
|
|
};
|
|
}
|