diff options
| author | Vitaly Magerya <vmagerya@gmail.com> | 2011-03-27 22:33:13 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-03-27 22:33:13 +0200 |
| commit | 700fbc308dd1f2e063180786cddfcc4abd6c10c0 (patch) | |
| tree | 4372252d571ae11392f3b4072dee7c3f52703b74 | |
| parent | a9e5c43b8b9b5d18b6aae08452fe2a3a46a248b4 (diff) | |
| download | busybox-w32-700fbc308dd1f2e063180786cddfcc4abd6c10c0.tar.gz busybox-w32-700fbc308dd1f2e063180786cddfcc4abd6c10c0.tar.bz2 busybox-w32-700fbc308dd1f2e063180786cddfcc4abd6c10c0.zip | |
wget: --post-data=STR should not encode STR, should send it verbatim
This matches GNU Wget 1.12 behavior.
Signed-off-by: Vitaly Magerya <vmagerya@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/wget.c | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/networking/wget.c b/networking/wget.c index c22a76b97..2f89c8f7f 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
| @@ -344,44 +344,6 @@ static char *gethdr(FILE *fp) | |||
| 344 | return hdrval; | 344 | return hdrval; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | ||
| 348 | static char *URL_escape(const char *str) | ||
| 349 | { | ||
| 350 | /* URL encode, see RFC 2396 */ | ||
| 351 | char *dst; | ||
| 352 | char *res = dst = xmalloc(strlen(str) * 3 + 1); | ||
| 353 | unsigned char c; | ||
| 354 | |||
| 355 | while (1) { | ||
| 356 | c = *str++; | ||
| 357 | if (c == '\0' | ||
| 358 | /* || strchr("!&'()*-.=_~", c) - more code */ | ||
| 359 | || c == '!' | ||
| 360 | || c == '&' | ||
| 361 | || c == '\'' | ||
| 362 | || c == '(' | ||
| 363 | || c == ')' | ||
| 364 | || c == '*' | ||
| 365 | || c == '-' | ||
| 366 | || c == '.' | ||
| 367 | || c == '=' | ||
| 368 | || c == '_' | ||
| 369 | || c == '~' | ||
| 370 | || (c >= '0' && c <= '9') | ||
| 371 | || ((c|0x20) >= 'a' && (c|0x20) <= 'z') | ||
| 372 | ) { | ||
| 373 | *dst++ = c; | ||
| 374 | if (c == '\0') | ||
| 375 | return res; | ||
| 376 | } else { | ||
| 377 | *dst++ = '%'; | ||
| 378 | *dst++ = bb_hexdigits_upcase[c >> 4]; | ||
| 379 | *dst++ = bb_hexdigits_upcase[c & 0xf]; | ||
| 380 | } | ||
| 381 | } | ||
| 382 | } | ||
| 383 | #endif | ||
| 384 | |||
| 385 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) | 347 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) |
| 386 | { | 348 | { |
| 387 | FILE *sfp; | 349 | FILE *sfp; |
| @@ -716,15 +678,13 @@ static void download_one_url(const char *url) | |||
| 716 | fputs(G.extra_headers, sfp); | 678 | fputs(G.extra_headers, sfp); |
| 717 | 679 | ||
| 718 | if (option_mask32 & WGET_OPT_POST_DATA) { | 680 | if (option_mask32 & WGET_OPT_POST_DATA) { |
| 719 | char *estr = URL_escape(G.post_data); | ||
| 720 | fprintf(sfp, | 681 | fprintf(sfp, |
| 721 | "Content-Type: application/x-www-form-urlencoded\r\n" | 682 | "Content-Type: application/x-www-form-urlencoded\r\n" |
| 722 | "Content-Length: %u\r\n" | 683 | "Content-Length: %u\r\n" |
| 723 | "\r\n" | 684 | "\r\n" |
| 724 | "%s", | 685 | "%s", |
| 725 | (int) strlen(estr), estr | 686 | (int) strlen(G.post_data), G.post_data |
| 726 | ); | 687 | ); |
| 727 | free(estr); | ||
| 728 | } else | 688 | } else |
| 729 | #endif | 689 | #endif |
| 730 | { | 690 | { |
