mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightning-cli: don't produce bad JSON if fields contain ".
The user can explicitly create such things (within [] or ") as we paste those cases literally, but not for the simple cases. Fixes: #2550 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
27afc804d5
commit
77b859eaec
@@ -790,6 +790,27 @@ def test_cli(node_factory):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Test it escapes JSON properly in both method and params.
|
||||
out = subprocess.run(['cli/lightning-cli',
|
||||
'--lightning-dir={}'
|
||||
.format(l1.daemon.lightning_dir),
|
||||
'x"[]{}'],
|
||||
stdout=subprocess.PIPE)
|
||||
assert 'Unknown command \'x\\"[]{}\'' in out.stdout.decode('utf-8')
|
||||
|
||||
subprocess.check_output(['cli/lightning-cli',
|
||||
'--lightning-dir={}'
|
||||
.format(l1.daemon.lightning_dir),
|
||||
'invoice', '123000', 'l"[]{}', 'd"[]{}']).decode('utf-8')
|
||||
# Check label is correct, and also that cli's keyword parsing works.
|
||||
out = subprocess.check_output(['cli/lightning-cli',
|
||||
'--lightning-dir={}'
|
||||
.format(l1.daemon.lightning_dir),
|
||||
'-k',
|
||||
'listinvoices', 'label=l"[]{}']).decode('utf-8')
|
||||
j = json.loads(out)
|
||||
assert only_one(j['invoices'])['label'] == 'l"[]{}'
|
||||
|
||||
|
||||
def test_daemon_option(node_factory):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user