comparison tests/test-ui-config.py @ 10982:0a548640e012

ui: support quotes in configlist (issue2147) Several places that use ui.configlist, predominantly in authentication scenarios need to interface with systems that can contain spaces in usernames (e.g. when client certificates are usernames, or Windows usernames). This changeset introduces a parser that supports quoting of strings, and escape quotation marks that get decoded into a single quotation mark that adopts the usual behavior one would expect from quoting strings. The Python library shlex module is not used, on purpose, as that raises if it cannot match quotation marks in the given input.
author Henrik Stuart <hg@hstuart.dk>
date Sun, 25 Apr 2010 17:38:41 +0200
parents 284fda4cd093
children ef7636efeb01
comparison
equal deleted inserted replaced
10981:c72358052e0b 10982:0a548640e012
9 'values.bool2=false', 9 'values.bool2=false',
10 'lists.list1=foo', 10 'lists.list1=foo',
11 'lists.list2=foo bar baz', 11 'lists.list2=foo bar baz',
12 'lists.list3=alice, bob', 12 'lists.list3=alice, bob',
13 'lists.list4=foo bar baz alice, bob', 13 'lists.list4=foo bar baz alice, bob',
14 'lists.list5=abc d"ef"g "hij def"',
15 'lists.list6="hello world", "how are you?"',
16 'lists.list7=Do"Not"Separate',
17 'lists.list8="Do"Separate',
18 'lists.list9="Do\\"NotSeparate"',
19 'lists.list10=string "with extraneous" quotation mark"',
20 'lists.list11=x, y',
21 'lists.list12="x", "y"',
22 'lists.list13=""" key = "x", "y" """',
23 'lists.list14=,,,, ',
24 'lists.list15=" just with starting quotation',
25 'lists.list16="longer quotation" with "no ending quotation',
26 'lists.list17=this is \\" "not a quotation mark"',
14 ]) 27 ])
15 28
16 print repr(testui.configitems('values')) 29 print repr(testui.configitems('values'))
17 print repr(testui.configitems('lists')) 30 print repr(testui.configitems('lists'))
18 print "---" 31 print "---"
34 print repr(testui.configlist('lists', 'list1')) 47 print repr(testui.configlist('lists', 'list1'))
35 print repr(testui.configlist('lists', 'list2')) 48 print repr(testui.configlist('lists', 'list2'))
36 print repr(testui.configlist('lists', 'list3')) 49 print repr(testui.configlist('lists', 'list3'))
37 print repr(testui.configlist('lists', 'list4')) 50 print repr(testui.configlist('lists', 'list4'))
38 print repr(testui.configlist('lists', 'list4', ['foo'])) 51 print repr(testui.configlist('lists', 'list4', ['foo']))
52 print repr(testui.configlist('lists', 'list5'))
53 print repr(testui.configlist('lists', 'list6'))
54 print repr(testui.configlist('lists', 'list7'))
55 print repr(testui.configlist('lists', 'list8'))
56 print repr(testui.configlist('lists', 'list9'))
57 print repr(testui.configlist('lists', 'list10'))
58 print repr(testui.configlist('lists', 'list11'))
59 print repr(testui.configlist('lists', 'list12'))
60 print repr(testui.configlist('lists', 'list13'))
61 print repr(testui.configlist('lists', 'list14'))
62 print repr(testui.configlist('lists', 'list15'))
63 print repr(testui.configlist('lists', 'list16'))
64 print repr(testui.configlist('lists', 'list17'))
39 print repr(testui.configlist('lists', 'unknown')) 65 print repr(testui.configlist('lists', 'unknown'))
40 print repr(testui.configlist('lists', 'unknown', '')) 66 print repr(testui.configlist('lists', 'unknown', ''))
41 print repr(testui.configlist('lists', 'unknown', 'foo')) 67 print repr(testui.configlist('lists', 'unknown', 'foo'))
42 print repr(testui.configlist('lists', 'unknown', ['foo'])) 68 print repr(testui.configlist('lists', 'unknown', ['foo']))
43 print repr(testui.configlist('lists', 'unknown', 'foo bar')) 69 print repr(testui.configlist('lists', 'unknown', 'foo bar'))