fix: Tighten valiation around URLs in database fields

closes #6012
This commit is contained in:
Tom Moor committed 2023-10-16 19:38:11 -04:00
1 parent 31cb9c865f
commit 0b7253bb0c
2 files changed
+23 -1

No files matched your search

+22
View File
@@ -13,6 +13,28 @@ afterAll(() => {
});
describe("user model", () => {
describe("create", () => {
it("should not allow URLs in name", async () => {
await expect(
buildUser({
name: "www.google.com",
})
).rejects.toThrowError();
await expect(
buildUser({
name: "My name https://malicious.com",
})
).rejects.toThrowError();
await expect(
buildUser({
name: "wwwww",
})
).resolves.toBeDefined();
});
});
describe("destroy", () => {
it("should delete user authentications", async () => {
const user = await buildUser();
+1 -1
View File
@@ -8,7 +8,7 @@ export default function NotContainsUrl(target: any, propertyName: string) {
return addAttributeOptions(target, propertyName, {
validate: {
not: {
args: /(www|file:|http:|https:)+[^\s]+[\w]/,
args: /(www\.|file:|http:|https:)[^\s]+[\w]/,
msg: "Must not contain a URL",
},
},