diff --git a/src/storage/limits.ts b/src/storage/limits.ts index cff8627d..7396332f 100644 --- a/src/storage/limits.ts +++ b/src/storage/limits.ts @@ -49,7 +49,7 @@ export async function isImageTransformationEnabled(tenantId: string) { export function isValidKey(key: string): boolean { // only allow s3 safe characters and characters which require special handling for now // https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html - return key.length > 0 && /^(\w|\/|!|-|\.|\*|'|\(|\)| |&|\$|@|=|;|:|\+|,|\?)*$/.test(key) + return key.length > 0 && /^[\p{L}\p{N}\p{M}\/!.\-*'()& $@=;:+,?]+\.[\p{L}\p{N}\p{M}]+$/u.test(key) } /** diff --git a/src/test/db/storage/limits.test.ts b/src/test/db/storage/limits.test.ts new file mode 100644 index 00000000..9188d9da --- /dev/null +++ b/src/test/db/storage/limits.test.ts @@ -0,0 +1,9 @@ +import { isValidKey } from "@storage/limits" + +describe("Testing limits", () => { + test("accept special characters as s3 object name", () => { + expect(isValidKey("望舌诊病.pdf")).toBe(true) + expect(isValidKey("ÖÄÜ.jpg")).toBe(true) + expect(isValidKey("åäö.png")).toBe(true) + }) +})