CSVs don't like ',' in the middle. We short circuit this * by wrapping the desc in double-quotes ("). But what if * there's already double-quotes? Well we swap these to * single-quotes (') and then use the json_escape function */
| 93 | * there's already double-quotes? Well we swap these to |
| 94 | * single-quotes (') and then use the json_escape function */ |
| 95 | static char *csv_safe_str(const tal_t *ctx, const char *input TAKES) |
| 96 | { |
| 97 | struct json_escape *esc; |
| 98 | char *dupe; |
| 99 | |
| 100 | /* Update the double-quotes in place */ |
| 101 | dupe = tal_strdup(tmpctx, input); |
| 102 | for (size_t i = 0; dupe[i] != '\0'; i++) { |
| 103 | if (dupe[i] == '"') |
| 104 | dupe[i] = '\''; |
| 105 | } |
| 106 | |
| 107 | esc = json_escape(tmpctx, take(dupe)); |
| 108 | return tal_fmt(ctx, "\"%s\"", esc->s); |
| 109 | } |
| 110 | |
| 111 | static struct income_event *maybe_chain_income(const tal_t *ctx, |
| 112 | const struct bkpr *bkpr, |
no test coverage detected