domain_parser must escape when quoting '"'
issue4247 review11571002
This commit is contained in:
1 parent
bcd57a5ab2
commit
d3b6a664de
1 file changed
+11
@@ -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():
|
||||
|
||||
Reference in new issue
Block a user