diff options
Diffstat (limited to 'src/commands.c')
| -rw-r--r-- | src/commands.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/commands.c b/src/commands.c index 72a8f70..a587ce3 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2655,7 +2655,7 @@ static yyjson_mut_val *h_settings_set(struct req *r) if (!key || !value) return fail(r, "INVALID_ARGS", "key and value are required"); size_t maxlen; - int digits_only = 0; + int digits_only = 0, bankgiro = 0; if (strcmp(key, "default_series") == 0) maxlen = 8; else if (strcmp(key, "attachment_dir") == 0) @@ -2665,6 +2665,9 @@ static yyjson_mut_val *h_settings_set(struct req *r) strcmp(key, "invoice_revenue_account") == 0) { maxlen = 10; digits_only = 1; + } else if (strcmp(key, "invoice_bankgiro") == 0) { + maxlen = 16; + bankgiro = 1; } else return fail(r, "UNSUPPORTED", "unknown setting"); size_t len = strlen(value); @@ -2674,6 +2677,9 @@ static yyjson_mut_val *h_settings_set(struct req *r) for (const char *p = value; *p; p++) { if (digits_only && (*p < '0' || *p > '9')) return failf(r, "INVALID_ARGS", "%s must be digits only", key); + if (bankgiro && !((*p >= '0' && *p <= '9') || *p == '-')) + return failf(r, "INVALID_ARGS", + "%s must be digits and hyphens", key); if ((unsigned char)*p < 32) return failf(r, "INVALID_ARGS", "%s must not contain control characters", key); |
