From dd805b3af59bff246089dcd6c584bfa58dabd212 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Sep 2024 13:44:31 +0200 Subject: [PATCH] fixup simplified the code for query trimming only --- trurl.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/trurl.c b/trurl.c index 513cd7b1..f0a4bb4f 100644 --- a/trurl.c +++ b/trurl.c @@ -652,13 +652,14 @@ static int getarg(struct option *o, *usedarg = gap; } else if(checkoptarg(o, "--trim", flag, arg)) { - trimadd(o, arg); + if(casecompare(arg, "query=", 6)) + errorf(o, ERROR_TRIM, "Unsupported trim component: %s", arg); + + trimadd(o, &arg[6]); *usedarg = gap; } else if(checkoptarg(o, "--qtrim", flag, arg)) { - char buffer[256]; - curl_msnprintf(buffer, sizeof(buffer), "query=%s", arg); - trimadd(o, buffer); + trimadd(o, arg); *usedarg = gap; } else if(checkoptarg(o, "-g", flag, arg) || @@ -1240,13 +1241,8 @@ static bool trim(struct option *o) bool query_is_modified = false; struct curl_slist *node; for(node = o->trim_list; node; node = node->next) { - char *ptr; - char *instr = node->data; - if(strncmp(instr, "query", 5)) - /* for now we can only trim query components */ - errorf(o, ERROR_TRIM, "Unsupported trim component: %s", instr); - ptr = strchr(instr, '='); - if(ptr && (ptr > instr)) { + char *ptr = node->data; + if(ptr) { /* 'ptr' should be a fixed string or a pattern ending with an asterisk */ size_t inslen; @@ -1254,7 +1250,6 @@ static bool trim(struct option *o) int i; char *temp = NULL; - ptr++; /* pass the = */ inslen = strlen(ptr); if(inslen) { pattern = ptr[inslen - 1] == '*';