mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
lightningd: refuse to create rune with empty fields.
These look like uniqueids, and so can confuse us (I discovered this by making a typo in a test!) Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
bb38f83b88
commit
ecb09778db
@ -419,6 +419,10 @@ static struct rune_altern *rune_altern_from_json(const tal_t *ctx,
|
||||
alt->fieldname = tal_strndup(alt, unescape, condoff);
|
||||
alt->condition = unescape[condoff];
|
||||
alt->value = tal_strdup(alt, unescape + condoff + 1);
|
||||
|
||||
/* don't let them add empty fieldnames */
|
||||
if (streq(alt->fieldname, ""))
|
||||
return tal_free(alt);
|
||||
return alt;
|
||||
}
|
||||
|
||||
|
@ -514,6 +514,14 @@ def test_missing_method_or_nodeid(node_factory):
|
||||
l1.rpc.checkrune(rune=rune4, nodeid=l1.info['id'])
|
||||
|
||||
|
||||
def test_invalid_restrictions(node_factory):
|
||||
# I meant "method!" not "!method"!
|
||||
l1 = node_factory.get_node()
|
||||
for cond in "!=/^$~<>{}#,":
|
||||
with pytest.raises(RpcError, match='not a valid restriction'):
|
||||
print(l1.rpc.createrune(restrictions=[[f"{cond}method"]]))
|
||||
|
||||
|
||||
def test_showrune_id(node_factory):
|
||||
l1 = node_factory.get_node()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user