From 833ec5bd393c4ef84f410dc1aff0661a9e4ac804 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 22 May 2026 17:33:29 +0200 Subject: [PATCH] Update browser extension autofill form detector (#2059) --- .../src/utils/formDetector/FormDetector.ts | 7 ++- .../__tests__/FormDetector.en.test.ts | 15 ++++++ .../__tests__/test-forms/fr-login-form2.html | 51 +++++++++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 apps/browser-extension/src/utils/formDetector/__tests__/test-forms/fr-login-form2.html diff --git a/apps/browser-extension/src/utils/formDetector/FormDetector.ts b/apps/browser-extension/src/utils/formDetector/FormDetector.ts index b6e2f725c..8666d6d73 100644 --- a/apps/browser-extension/src/utils/formDetector/FormDetector.ts +++ b/apps/browser-extension/src/utils/formDetector/FormDetector.ts @@ -232,8 +232,7 @@ export class FormDetector { * But NOT within another word: "research" (re-search), "birthdate" (date) */ const wordBoundaryPattern = new RegExp( - `(^|[\\s\\-_]|(?<=[a-z])(?=[A-Z]))${pattern}($|[\\s\\-_]|(?<=[a-z])(?=[A-Z]))`, - 'i' + `(^|[\\s\\-_]|(?<=[a-z])(?=[A-Z]))${pattern}($|[\\s\\-_]|(?<=[a-z])(?=[A-Z]))` ); return wordBoundaryPattern.test(text); @@ -721,13 +720,13 @@ export class FormDetector { } // If email type is explicitly requested, prefer actual - if (types.includes('email') && type === 'email') { + if (entry === CombinedFieldPatterns.email && types.includes('email') && type === 'email') { matches.push({ input: input as HTMLInputElement, score: -1 }); continue; } // If password type is explicitly requested, prefer actual - if (types.includes('password') && type === 'password') { + if (entry === CombinedFieldPatterns.password && types.includes('password') && type === 'password') { matches.push({ input: input as HTMLInputElement, score: -1 }); continue; } diff --git a/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.en.test.ts b/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.en.test.ts index 3dec545da..62d835152 100644 --- a/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.en.test.ts +++ b/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.en.test.ts @@ -100,6 +100,21 @@ describe('FormDetector English tests', () => { testField(FormField.Username, 'spi_tmp', htmlFile); }); + describe('French login form 2 detection (Plurilogic password page)', () => { + const htmlFile = 'fr-login-form2.html'; + + testField(FormField.Password, 'MotPasse', htmlFile); + + it('should not misclassify the password field as TOTP', () => { + const dom = createTestDom(htmlFile); + const document = dom.window.document; + const focusedElement = document.getElementById('MotPasse'); + const formDetector = new FormDetector(document, focusedElement); + const result = formDetector.getForm(); + expect(result?.totpField).toBeNull(); + }); + }); + describe('English passwordless signup form 1 detection', () => { const htmlFile = 'en-signup-passwordless-1.html'; diff --git a/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/fr-login-form2.html b/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/fr-login-form2.html new file mode 100644 index 000000000..2efab98b1 --- /dev/null +++ b/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/fr-login-form2.html @@ -0,0 +1,51 @@ + + + +
+ + + + + + + + + +
+ +