| 783 | } |
| 784 | |
| 785 | static struct rune_restr *rune_restr_from_json(const tal_t *ctx, |
| 786 | const char *buffer, |
| 787 | const jsmntok_t *tok) |
| 788 | { |
| 789 | const jsmntok_t *t; |
| 790 | size_t i; |
| 791 | struct rune_restr *restr; |
| 792 | |
| 793 | /* \| is not valid JSON, so they use \\|: undo it! */ |
| 794 | if (deprecated_apis && tok->type == JSMN_STRING) { |
| 795 | const char *unescape; |
| 796 | struct json_escape *e = json_escape_string_(tmpctx, |
| 797 | buffer + tok->start, |
| 798 | tok->end - tok->start); |
| 799 | unescape = json_escape_unescape(tmpctx, e); |
| 800 | if (!unescape) |
| 801 | return NULL; |
| 802 | return rune_restr_from_string(ctx, unescape, strlen(unescape)); |
| 803 | } |
| 804 | |
| 805 | restr = tal(ctx, struct rune_restr); |
| 806 | /* FIXME: after deprecation removed, allow singletons again! */ |
| 807 | if (tok->type != JSMN_ARRAY) |
| 808 | return NULL; |
| 809 | |
| 810 | restr->alterns = tal_arr(restr, struct rune_altern *, tok->size); |
| 811 | json_for_each_arr(i, t, tok) { |
| 812 | restr->alterns[i] = rune_altern_from_json(restr->alterns, |
| 813 | buffer, t); |
| 814 | if (!restr->alterns[i]) |
| 815 | return tal_free(restr); |
| 816 | } |
| 817 | return restr; |
| 818 | } |
| 819 | |
| 820 | static struct command_result *param_restrictions(struct command *cmd, |
| 821 | const char *name, |
no test coverage detected