From 1bdd34c8fbea5930174b11528c2f144adad5b35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Miernik?= Date: Tue, 15 Feb 2022 11:43:25 +0100 Subject: [PATCH] Removed negative lookbehind (fixes #1088). --- packages/uniforms/__tests__/joinName.ts | 7 +++++++ packages/uniforms/src/joinName.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/uniforms/__tests__/joinName.ts b/packages/uniforms/__tests__/joinName.ts index d475acc86..0da4c9c1d 100644 --- a/packages/uniforms/__tests__/joinName.ts +++ b/packages/uniforms/__tests__/joinName.ts @@ -124,5 +124,12 @@ describe('joinName', () => { test(["['']"], ['["[\'\']"]'], '["[\'\']"]'); test(['["'], ['["[\\""]'], '["[\\""]'); test(['[""'], ['["[\\"\\""]'], '["[\\"\\""]'); + + // Incorrect escape. + test(['["a\\"]'], ['["[\\"a\\\\"]"]'], '["[\\"a\\\\"]"]'); + test(['[\\""]'], ['["[\\\\"\\"]"]'], '["[\\\\"\\"]"]'); + test(['[\\"a"]'], ['["[\\\\"a\\"]"]'], '["[\\\\"a\\"]"]'); + test(['["\\"]'], ['["[\\"\\\\"]"]'], '["[\\"\\\\"]"]'); + test(['["\\"\\"]'], ['["[\\"\\\\"\\\\"]"]'], '["[\\"\\\\"\\\\"]"]'); }); }); diff --git a/packages/uniforms/src/joinName.ts b/packages/uniforms/src/joinName.ts index e6b4d6651..8b15fef26 100644 --- a/packages/uniforms/src/joinName.ts +++ b/packages/uniforms/src/joinName.ts @@ -34,7 +34,7 @@ function unescape(string: string) { // // All three parts can be empty! const nameRegex = - /^([^.[\]]*(?:\.[^.[\]]+)*)(?:\.?(\["(?:[^"]|\\")*?(?