|
41 | 41 | #include "tool_paramhlp.h" |
42 | 42 | #include "tool_parsecfg.h" |
43 | 43 | #include "tool_main.h" |
| 44 | +#include "dynbuf.h" |
44 | 45 |
|
45 | 46 | #include "memdebug.h" /* keep this as LAST include */ |
46 | 47 |
|
@@ -233,6 +234,7 @@ static const struct LongShort aliases[]= { |
233 | 234 | {"db", "data-binary", ARG_STRING}, |
234 | 235 | {"de", "data-urlencode", ARG_STRING}, |
235 | 236 | {"df", "json", ARG_STRING}, |
| 237 | + {"dg", "url-query", ARG_STRING}, |
236 | 238 | {"D", "dump-header", ARG_FILENAME}, |
237 | 239 | {"e", "referer", ARG_STRING}, |
238 | 240 | {"E", "cert", ARG_FILENAME}, |
@@ -1567,7 +1569,39 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ |
1567 | 1569 | size_t size = 0; |
1568 | 1570 | bool raw_mode = (subletter == 'r'); |
1569 | 1571 |
|
1570 | | - if(subletter == 'e') { /* --data-urlencode */ |
| 1572 | + if(subletter == 'g') { /* --url-query */ |
| 1573 | +#define MAX_QUERY_LEN 100000 /* larger is not likely to ever work */ |
| 1574 | + char *query; |
| 1575 | + struct curlx_dynbuf dyn; |
| 1576 | + curlx_dyn_init(&dyn, MAX_QUERY_LEN); |
| 1577 | + |
| 1578 | + if(*nextarg == '+') { |
| 1579 | + /* use without encoding */ |
| 1580 | + query = strdup(&nextarg[1]); |
| 1581 | + if(!query) |
| 1582 | + return PARAM_NO_MEM; |
| 1583 | + } |
| 1584 | + else { |
| 1585 | + err = data_urlencode(global, nextarg, &query, &size); |
| 1586 | + if(err) |
| 1587 | + return err; |
| 1588 | + } |
| 1589 | + |
| 1590 | + if(config->query) { |
| 1591 | + CURLcode result = |
| 1592 | + curlx_dyn_addf(&dyn, "%s&%s", config->query, query); |
| 1593 | + free(query); |
| 1594 | + if(result) |
| 1595 | + return PARAM_NO_MEM; |
| 1596 | + free(config->query); |
| 1597 | + config->query = curlx_dyn_ptr(&dyn); |
| 1598 | + } |
| 1599 | + else |
| 1600 | + config->query = query; |
| 1601 | + |
| 1602 | + break; /* this is not a POST argument at all */ |
| 1603 | + } |
| 1604 | + else if(subletter == 'e') { /* --data-urlencode */ |
1571 | 1605 | err = data_urlencode(global, nextarg, &postdata, &size); |
1572 | 1606 | if(err) |
1573 | 1607 | return err; |
|
0 commit comments