diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-04-27 13:59:49 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-04-27 13:59:49 +0000 |
| commit | f08b5d22a4a39c3cb83585947506c0550b36f972 (patch) | |
| tree | cc8df410aa444f9c6f583a291d13b5bdbffc203c /addons/web/static/lib | |
| parent | 7b402c5e59282eb9100adede97e730cdc73da690 (diff) | |
[IMP] web: handling of escaping in literals
Handling of escapes (`\`) was performed during evaluation rather than
parsing, so strings in the AST stored the escaped form (rather than
the proper one), and _formatAST had to mess around in order to try and
get it back into a semblance of relevance (especially as the AST would
store the escaped string without delimiters).
Fix: perform the escapes handling (aka normalisation) during
tokenization where it belongs. This means the AST formatter can now
just JSON.stringify the data. Until and unless we decide to produce a
cpython-compliant
repr (https://github.com/python/cpython/blob/0169d3003be3d072751dd14a5c84748ab63a249f/Objects/unicodeobject.c#L12902-L13006)
which is unlikely.
closes odoo/odoo#50236
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/web/static/lib')
| -rw-r--r-- | addons/web/static/lib/py.js/lib/py.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/web/static/lib/py.js/lib/py.js b/addons/web/static/lib/py.js/lib/py.js index bcc24cd520d..7ba8107937d 100644 --- a/addons/web/static/lib/py.js/lib/py.js +++ b/addons/web/static/lib/py.js/lib/py.js @@ -308,10 +308,11 @@ var py = {}; })); } else if (string_pattern.test(token)) { var m = string_pattern.exec(token); - var value = (m[3] !== undefined ? m[3] : m[5]); tokens.push(create(symbols['(string)'], { - unicode: !!(m[2] || m[4]), - value: value + value: PY_decode_string_literal( + m[3] !== undefined ? m[3] : m[5], + !!(m[2] || m[4]) + ) })); } else if (token in symbols) { var symbol; @@ -1350,8 +1351,7 @@ var py = {}; } return PY_ensurepy(val, expr.value); case '(string)': - return py.str.fromJSON(PY_decode_string_literal( - expr.value, expr.unicode)); + return py.str.fromJSON(expr.value); case '(number)': return py.float.fromJSON(expr.value); case '(constant)': |
