diff options
| author | Mathieu Duckerts-Antoine <dam@odoo.com> | 2018-12-26 16:01:18 +0000 |
|---|---|---|
| committer | Mathieu Duckerts-Antoine <dam@odoo.com> | 2019-02-12 12:45:51 +0000 |
| commit | 01c159fd9fefd9863d2eed5a1f75f709595de294 (patch) | |
| tree | 1a3c6cf5fe68a46c584c487d6ed48c2dcb7fccdd /addons/web/static/lib/py.js | |
| parent | 6d5a993cf74173456734cccd2ea2c13027c04bbd (diff) | |
[FIX] web: quotes and backslashes in search view
The commit 6d3ada178f7caf6ea159b871648ca4c440c7845b
aimed to solve problems occuring whith (single or
double) quotes when creating new custom filters.
Unfortunately, the point was missed and bugs were
still present. The present commit solves the
orginial problem satisfactorily.
There was also a problem in the management of
backslashes. Type '\\' in the search bar would
lead to a domain like
[('...', 'ilike', '\\\\\\\\\\\\\\\\')].
This has also been fixed. Note that it is
necessary to input "\\" if one is looking for a
backslash in db (as before).
A remark on the _formatAST function (py_utils.js):
We deescape only the chars `'`, `"`, and `\`
because it does not seem possible to produce a
string in the search view that would intend a
search for a line return or a tab for example.
A general remark:
Domains should always be in normalized form.
In that way they could be manipulated and combined
together without a tokenization/parsing!
closes odoo/odoo#29756
Diffstat (limited to 'addons/web/static/lib/py.js')
| -rw-r--r-- | addons/web/static/lib/py.js/lib/py.js | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/addons/web/static/lib/py.js/lib/py.js b/addons/web/static/lib/py.js/lib/py.js index bd794323995..60b80a7f439 100644 --- a/addons/web/static/lib/py.js/lib/py.js +++ b/addons/web/static/lib/py.js/lib/py.js @@ -273,8 +273,7 @@ var py = {}; var Special = '[:;.,`@]'; var Funny = group(Operator, Bracket, Special); - var ContStr = group("([uU])?'([^']*)'", '([uU])?"([^"]*)"'); - + var ContStr = group("([uU])?'([^\n'\\\\]*(?:\\\\.[^\n'\\\\]*)*)'", '([uU])?"([^\n"\\\\]*(?:\\\\.[^\n"\\\\]*)*)"'); var PseudoToken = Whitespace + group(Number, Funny, ContStr, Name); var number_pattern = new RegExp('^' + Number + '$'); @@ -282,9 +281,6 @@ var py = {}; var name_pattern = new RegExp('^' + Name + '$'); var strip = new RegExp('^' + Whitespace); return function tokenize(s) { - s = s - .replace(/\\\"/g, '\\u0022') // for double quote - .replace(/\\\'/g, '\\u0027'); // for single quote var max=s.length, tokens = [], start, end; // /g flag makes repeated exec() have memory var pseudoprog = new RegExp(PseudoToken, 'g'); @@ -313,9 +309,6 @@ var py = {}; } else if (string_pattern.test(token)) { var m = string_pattern.exec(token); var value = (m[3] !== undefined ? m[3] : m[5]); - value - .replace(/\\u0022/g, '"') - .replace(/\\u0027/g, "'"); tokens.push(create(symbols['(string)'], { unicode: !!(m[2] || m[4]), value: value |
