Bug 1935981 - Improve "given-name" heuristic for Japan r=NeilDeakin,credential-management-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D266778
This commit is contained in:
Dimi authored and [email protected] committed 2025-11-11 10:22:22 +00:00
1 parent fc74e7d237
commit 1690825dc3
1 file changed
+9 -2
@@ -555,7 +555,7 @@ export const HeuristicsRegExp = {
"|vorname" + // de-DE
"|nombre" + // es
"|forename|prénom|prenom" + // fr-FR
"|名" + // ja-JP
"|(^|[^\\p{L}\\p{N}])名([^\\p{L}\\p{N}]|$)" + // ja-JP
"|nome" + // pt-BR, pt-PT
"|Имя" + // ru
"|نام" + // fa
@@ -692,7 +692,14 @@ export const HeuristicsRegExp = {
// lower-cased field name and get a rough equivalent of a case-insensitive
// match. This avoids a performance cliff with the "iu" flag on regular
// expressions.
regexps.push(`(${set[name].toLowerCase()})`.normalize("NFKC"));
let pattern = `(${set[name].toLowerCase()})`.normalize("NFKC");
// We should not lower case the \p{L} & \p{N} parts of the pattern,
// revert them back.
pattern = pattern.replaceAll("\\p{l}", "\\p{L}");
pattern = pattern.replaceAll("\\p{n}", "\\p{N}");
regexps.push(pattern);
}
});