mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
json_getnodes: escape the alias when we print it out.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
76e8a11380
commit
4139f06780
@ -11,6 +11,7 @@
|
|||||||
#include <ccan/take/take.h>
|
#include <ccan/take/take.h>
|
||||||
#include <ccan/tal/str/str.h>
|
#include <ccan/tal/str/str.h>
|
||||||
#include <common/features.h>
|
#include <common/features.h>
|
||||||
|
#include <common/json_escaped.h>
|
||||||
#include <common/type_to_string.h>
|
#include <common/type_to_string.h>
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -231,15 +232,16 @@ static void json_getnodes_reply(struct subd *gossip UNUSED, const u8 *reply,
|
|||||||
json_array_start(response, "nodes");
|
json_array_start(response, "nodes");
|
||||||
|
|
||||||
for (i = 0; i < tal_count(nodes); i++) {
|
for (i = 0; i < tal_count(nodes); i++) {
|
||||||
|
struct json_escaped *esc;
|
||||||
|
|
||||||
json_object_start(response, NULL);
|
json_object_start(response, NULL);
|
||||||
json_add_pubkey(response, "nodeid", &nodes[i]->nodeid);
|
json_add_pubkey(response, "nodeid", &nodes[i]->nodeid);
|
||||||
if (nodes[i]->last_timestamp < 0) {
|
if (nodes[i]->last_timestamp < 0) {
|
||||||
json_object_end(response);
|
json_object_end(response);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
json_add_string(response, "alias",
|
esc = json_escape(NULL, (const char *)nodes[i]->alias);
|
||||||
tal_strndup(response, (char *)nodes[i]->alias,
|
json_add_escaped_string(response, "alias", take(esc));
|
||||||
tal_len(nodes[i]->alias)));
|
|
||||||
json_add_hex(response, "color",
|
json_add_hex(response, "color",
|
||||||
nodes[i]->color, ARRAY_SIZE(nodes[i]->color));
|
nodes[i]->color, ARRAY_SIZE(nodes[i]->color));
|
||||||
json_add_u64(response, "last_timestamp",
|
json_add_u64(response, "last_timestamp",
|
||||||
|
@ -2127,10 +2127,9 @@ class LightningDTests(BaseLightningDTests):
|
|||||||
.format(l1.info['id']))
|
.format(l1.info['id']))
|
||||||
|
|
||||||
node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
|
node = l1.rpc.listnodes(l1.info['id'])['nodes'][0]
|
||||||
# FIXME: We get this wrong!
|
assert node['alias'] == weird_name
|
||||||
assert not node['alias'] == weird_name
|
|
||||||
node = l2.rpc.listnodes(l1.info['id'])['nodes'][0]
|
node = l2.rpc.listnodes(l1.info['id'])['nodes'][0]
|
||||||
assert not node['alias'] == weird_name
|
assert node['alias'] == weird_name
|
||||||
|
|
||||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
|
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for --dev-broadcast-interval")
|
||||||
def test_gossip_pruning(self):
|
def test_gossip_pruning(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user