From d3b6a664de2a41d2e8dcf507698233883045edab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 14 Oct 2014 15:21:53 +0200 Subject: [PATCH] domain_parser must escape when quoting '"' issue4247 review11571002 --- tryton/common/domain_parser.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tryton/common/domain_parser.py b/tryton/common/domain_parser.py index 24e2eb8460..6006702303 100644 --- a/tryton/common/domain_parser.py +++ b/tryton/common/domain_parser.py @@ -117,12 +117,20 @@ def quote(value): "Quote string if needed" if not isinstance(value, basestring): return value + if '"' in value: + value = value.replace('"', '\\"') for test in (':', ' ', '(', ')') + OPERATORS: if test in value: return '"%s"' % value return value +def test_quote(): + assert quote('test') == 'test' + assert quote('foo bar') == '"foo bar"' + assert quote('"foo"') == '\\\"foo\\\"' + + def ending_clause(domain, deep=0): "Return the ending clause" if not domain: @@ -1284,6 +1292,9 @@ def test_group(): ('Name', '=', None), ('Name', None, 'Doe'), ] + assert rlist(dom.group(udlex(u'Name: \\"foo\\"'))) == [ + ('Name', None, '"foo"'), + ] def test_parse_clause():