details: https://code.tryton.org/tryton/commit/667b0be45487
branch: 7.0
user: Cédric Krier <[email protected]>
date: Thu Aug 06 16:15:44 2026 +0200
description:
Escape metacharacters from thousand separator before using it in replace
Closes #14971
diffstat:
sao/src/common.js | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diffs (23 lines):
diff -r 6d8466cf9e15 -r 667b0be45487 sao/src/common.js
--- a/sao/src/common.js Tue Aug 04 12:22:59 2026 +0200
+++ b/sao/src/common.js Thu Aug 06 16:15:44 2026 +0200
@@ -2095,6 +2095,9 @@
if (!string) {
throw("empty string");
}
+ function escapeRegExp(str) {
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ }
let { format } = new Intl.NumberFormat(
Sao.i18n.BC47(Sao.i18n.getlang()));
// use 10000 because some language (ex: es) add thousand
@@ -2103,7 +2106,8 @@
let [, decimalSign] = /^0(.)1$/.exec(format(0.1));
return Number(string
.replace(new RegExp(' ', 'g'), '')
- .replace(new RegExp(thousandSeparator, 'g'), '')
+ .replace(new RegExp(
+ escapeRegExp(thousandSeparator), 'g'), '')
.replace(decimalSign, '.'));
}
var convert_selection = function() {