diff options
Diffstat (limited to 'networking/wget.c')
-rw-r--r-- | networking/wget.c | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/networking/wget.c b/networking/wget.c index 41ec7f6dc..5f6e8155f 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; |
@@ -445,7 +407,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_ | |||
445 | str = strrchr(G.wget_buf, ','); | 407 | str = strrchr(G.wget_buf, ','); |
446 | if (!str) goto pasv_error; | 408 | if (!str) goto pasv_error; |
447 | port += xatou_range(str+1, 0, 255) * 256; | 409 | port += xatou_range(str+1, 0, 255) * 256; |
448 | set_nport(lsa, htons(port)); | 410 | set_nport(&lsa->u.sa, htons(port)); |
449 | 411 | ||
450 | *dfpp = open_socket(lsa); | 412 | *dfpp = open_socket(lsa); |
451 | 413 | ||
@@ -699,6 +661,12 @@ static void download_one_url(const char *url) | |||
699 | 661 | ||
700 | #if ENABLE_FEATURE_WGET_AUTHENTICATION | 662 | #if ENABLE_FEATURE_WGET_AUTHENTICATION |
701 | if (target.user) { | 663 | if (target.user) { |
664 | //TODO: URL-decode "user:password" string before base64-encoding: | ||
665 | //wget http://test:my%20pass@example.com should send | ||
666 | // Authorization: Basic dGVzdDpteSBwYXNz | ||
667 | //which decodes to "test:my pass", instead of what we send now: | ||
668 | // Authorization: Basic dGVzdDpteSUyMHBhc3M= | ||
669 | //Can reuse decodeString() from httpd.c | ||
702 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, | 670 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, |
703 | base64enc(target.user)); | 671 | base64enc(target.user)); |
704 | } | 672 | } |
@@ -716,15 +684,13 @@ static void download_one_url(const char *url) | |||
716 | fputs(G.extra_headers, sfp); | 684 | fputs(G.extra_headers, sfp); |
717 | 685 | ||
718 | if (option_mask32 & WGET_OPT_POST_DATA) { | 686 | if (option_mask32 & WGET_OPT_POST_DATA) { |
719 | char *estr = URL_escape(G.post_data); | ||
720 | fprintf(sfp, | 687 | fprintf(sfp, |
721 | "Content-Type: application/x-www-form-urlencoded\r\n" | 688 | "Content-Type: application/x-www-form-urlencoded\r\n" |
722 | "Content-Length: %u\r\n" | 689 | "Content-Length: %u\r\n" |
723 | "\r\n" | 690 | "\r\n" |
724 | "%s", | 691 | "%s", |
725 | (int) strlen(estr), estr | 692 | (int) strlen(G.post_data), G.post_data |
726 | ); | 693 | ); |
727 | free(estr); | ||
728 | } else | 694 | } else |
729 | #endif | 695 | #endif |
730 | { | 696 | { |