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 */
| 110 | * there's already double-quotes? Well we swap these to |
| 111 | * single-quotes (') and then use the json_escape function */ |
| 112 | static char *csv_safe_str(const tal_t *ctx, char *input TAKES) |
| 113 | { |
| 114 | struct json_escape *esc; |
| 115 | char *dupe; |
| 116 | |
| 117 | /* Update the double-quotes in place */ |
| 118 | dupe = tal_strdup(tmpctx, input); |
| 119 | for (size_t i = 0; dupe[i] != '\0'; i++) { |
| 120 | if (dupe[i] == '"') |
| 121 | dupe[i] = '\''; |
| 122 | } |
| 123 | |
| 124 | esc = json_escape(tmpctx, take(dupe)); |
| 125 | return tal_fmt(ctx, "\"%s\"", esc->s); |
| 126 | } |
| 127 | |
| 128 | static struct income_event *maybe_chain_income(const tal_t *ctx, |
| 129 | struct db *db, |
no test coverage detected