2492
2506
/* postfield data */
2494
char *postdata=NULL;
2497
if(subletter == 'e') { /* --data-urlencode*/
2498
/* [name]=[content], we encode the content part only
2499
* [name]@[file name]
2501
* Case 2: we first load the file using that name and then encode
2504
const char *p = strchr(nextarg, '=');
2509
/* there was no '=' letter, check for a '@' instead */
2510
p = strchr(nextarg, '@');
2512
nlen = p - nextarg; /* length of the name part */
2513
is_file = *p++; /* pass the separator */
2516
/* neither @ nor =, so no name and it isn't a file */
2520
if('@' == is_file) {
2521
/* a '@' letter, it means that a file name or - (stdin) follows */
2523
if(curlx_strequal("-", p)) {
2528
file = fopen(p, "rb");
2531
"Couldn't read data from file \"%s\", this makes "
2532
"an empty POST.\n", nextarg);
2535
err = file2memory(&postdata, &size, file);
2537
if(file && (file != stdin))
2543
GetStr(&postdata, p);
2544
size = strlen(postdata);
2548
/* no data from the file, point to a zero byte string to make this
2549
get sent as a POST anyway */
2550
postdata=strdup("");
2553
char *enc = curl_easy_escape(config->easy, postdata, (int)size);
2554
free(postdata); /* no matter if it worked or not */
2556
/* now make a string with the name from above and append the
2558
size_t outlen = nlen + strlen(enc) + 2;
2559
char *n = malloc(outlen);
2562
return PARAM_NO_MEM;
2564
if (nlen > 0) /* only append '=' if we have a name */
2565
snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
2572
return PARAM_NO_MEM;
2575
else if('@' == *nextarg) {
2577
/* the data begins with a '@' letter, it means that a file name
2578
or - (stdin) follows */
2579
nextarg++; /* pass the @ */
2581
if(curlx_strequal("-", nextarg)) {
2508
char *postdata=NULL;
2511
if(subletter == 'e') { /* --data-urlencode*/
2512
/* [name]=[content], we encode the content part only
2513
* [name]@[file name]
2515
* Case 2: we first load the file using that name and then encode
2518
const char *p = strchr(nextarg, '=');
2523
/* there was no '=' letter, check for a '@' instead */
2524
p = strchr(nextarg, '@');
2526
nlen = p - nextarg; /* length of the name part */
2527
is_file = *p++; /* pass the separator */
2530
/* neither @ nor =, so no name and it isn't a file */
2534
if('@' == is_file) {
2535
/* a '@' letter, it means that a file name or - (stdin) follows */
2537
if(curlx_strequal("-", p)) {
2583
if(subletter == 'b') /* forced data-binary */
2587
file = fopen(nextarg, "rb");
2542
file = fopen(p, "rb");
2589
warnf(config, "Couldn't read data from file \"%s\", this makes "
2545
"Couldn't read data from file \"%s\", this makes "
2590
2546
"an empty POST.\n", nextarg);
2593
if(subletter == 'b') {
2595
err = file2memory(&postdata, &size, file);
2596
config->postfieldsize = (curl_off_t)size;
2599
err = file2string(&postdata, file);
2549
err = file2memory(&postdata, &size, file);
2601
2551
if(file && (file != stdin))
2557
GetStr(&postdata, p);
2558
size = strlen(postdata);
2607
/* no data from the file, point to a zero byte string to make this
2608
get sent as a POST anyway */
2609
postdata=strdup("");
2562
/* no data from the file, point to a zero byte string to make this
2563
get sent as a POST anyway */
2564
postdata=strdup("");
2567
char *enc = curl_easy_escape(config->easy, postdata, (int)size);
2568
free(postdata); /* no matter if it worked or not */
2570
/* now make a string with the name from above and append the
2572
size_t outlen = nlen + strlen(enc) + 2;
2573
char *n = malloc(outlen);
2576
return PARAM_NO_MEM;
2578
if(nlen > 0) /* only append '=' if we have a name */
2579
snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
2613
GetStr(&postdata, nextarg);
2616
#ifdef CURL_DOES_CONVERSIONS
2617
if(subletter != 'b') { /* NOT forced binary, convert to ASCII */
2618
convert_to_network(postdata, strlen(postdata));
2622
if(config->postfields) {
2623
/* we already have a string, we append this one
2624
with a separating &-letter */
2625
char *oldpost=config->postfields;
2626
size_t newlen = strlen(oldpost) + strlen(postdata) + 2;
2627
config->postfields=malloc(newlen);
2628
if(!config->postfields) {
2630
2586
return PARAM_NO_MEM;
2632
/* use ASCII value 0x26 for '&' to accommodate non-ASCII platforms */
2633
snprintf(config->postfields, newlen, "%s\x26%s", oldpost, postdata);
2589
else if('@' == *nextarg) {
2591
/* the data begins with a '@' letter, it means that a file name
2592
or - (stdin) follows */
2593
nextarg++; /* pass the @ */
2595
if(curlx_strequal("-", nextarg)) {
2597
if(subletter == 'b') /* forced data-binary */
2601
file = fopen(nextarg, "rb");
2603
warnf(config, "Couldn't read data from file \"%s\", this makes "
2604
"an empty POST.\n", nextarg);
2607
if(subletter == 'b') {
2609
err = file2memory(&postdata, &size, file);
2610
config->postfieldsize = (curl_off_t)size;
2613
err = file2string(&postdata, file);
2615
if(file && (file != stdin))
2621
/* no data from the file, point to a zero byte string to make this
2622
get sent as a POST anyway */
2623
postdata=strdup("");
2627
GetStr(&postdata, nextarg);
2630
#ifdef CURL_DOES_CONVERSIONS
2631
if(subletter != 'b') { /* NOT forced binary, convert to ASCII */
2632
convert_to_network(postdata, strlen(postdata));
2636
if(config->postfields) {
2637
/* we already have a string, we append this one
2638
with a separating &-letter */
2639
char *oldpost=config->postfields;
2640
size_t newlen = strlen(oldpost) + strlen(postdata) + 2;
2641
config->postfields=malloc(newlen);
2642
if(!config->postfields) {
2635
2643
free(postdata);
2644
return PARAM_NO_MEM;
2638
config->postfields=postdata;
2646
/* use ASCII value 0x26 for '&' to accommodate non-ASCII platforms */
2647
snprintf(config->postfields, newlen, "%s\x26%s", oldpost, postdata);
2641
We can't set the request type here, as this data might be used in
2642
a simple GET if -G is used. Already or soon.
2652
config->postfields=postdata;
2655
We can't set the request type here, as this data might be used in
2656
a simple GET if -G is used. Already or soon.
2644
if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq))
2645
return PARAM_BAD_USE;
2658
if(SetHTTPrequest(HTTPREQ_SIMPLEPOST, &config->httpreq))
2659
return PARAM_BAD_USE;
2649
2663
/* dump-header to given file name */
2650
2664
GetStr(&config->headerfile, nextarg);
2654
char *ptr = strstr(nextarg, ";auto");
2656
/* Automatic referer requested, this may be combined with a
2658
config->autoreferer = TRUE;
2659
*ptr = 0; /* zero terminate here */
2662
config->autoreferer = FALSE;
2663
GetStr(&config->referer, nextarg);
2668
char *ptr = strstr(nextarg, ";auto");
2670
/* Automatic referer requested, this may be combined with a
2672
config->autoreferer = TRUE;
2673
*ptr = 0; /* zero terminate here */
2676
config->autoreferer = FALSE;
2677
GetStr(&config->referer, nextarg);
2667
2681
switch(subletter) {
2668
2682
case 'a': /* CA info PEM file */
2697
2711
case 'i': /* --hostpubmd5 md5 of the host public key */
2698
2712
GetStr(&config->hostpubmd5, nextarg);
2699
if (!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
2700
return PARAM_BAD_USE;
2713
if(!config->hostpubmd5 || strlen(config->hostpubmd5) != 32)
2714
return PARAM_BAD_USE;
2702
2716
case 'j': /* CRL info PEM file */
2704
2718
GetStr(&config->crlfile, nextarg);
2706
2720
default: /* certificate file */
2708
char *ptr = strchr(nextarg, ':');
2709
/* Since we live in a world of weirdness and confusion, the win32
2710
dudes can use : when using drive letters and thus
2711
c:\file:password needs to work. In order not to break
2712
compatibility, we still use : as separator, but we try to detect
2713
when it is used for a file name! On windows. */
2722
char *ptr = strchr(nextarg, ':');
2723
/* Since we live in a world of weirdness and confusion, the win32
2724
dudes can use : when using drive letters and thus
2725
c:\file:password needs to work. In order not to break
2726
compatibility, we still use : as separator, but we try to detect
2727
when it is used for a file name! On windows. */
2716
(ptr == &nextarg[1]) &&
2717
(nextarg[2] == '\\' || nextarg[2] == '/') &&
2718
(ISALPHA(nextarg[0])) )
2719
/* colon in the second column, followed by a backslash, and the
2720
first character is an alphabetic letter:
2730
(ptr == &nextarg[1]) &&
2731
(nextarg[2] == '\\' || nextarg[2] == '/') &&
2732
(ISALPHA(nextarg[0])) )
2733
/* colon in the second column, followed by a backslash, and the
2734
first character is an alphabetic letter:
2722
this is a drive letter colon */
2723
ptr = strchr(&nextarg[3], ':'); /* find the next one instead */
2736
this is a drive letter colon */
2737
ptr = strchr(&nextarg[3], ':'); /* find the next one instead */
2726
/* we have a password too */
2729
GetStr(&config->key_passwd, ptr);
2731
GetStr(&config->cert, nextarg);
2740
/* we have a password too */
2743
GetStr(&config->key_passwd, ptr);
2745
GetStr(&config->cert, nextarg);
2860
2874
config->default_node_flags = toggle?GETOUT_USEREMOTE:0;
2864
2878
case 'o': /* --output */
2865
2879
/* output file */
2868
if(config->url_out || (config->url_out=config->url_list)) {
2869
/* there's a node here, if it already is filled-in continue to find
2871
while(config->url_out && (config->url_out->flags&GETOUT_OUTFILE))
2872
config->url_out = config->url_out->next;
2882
if(config->url_out || (config->url_out=config->url_list)) {
2883
/* there's a node here, if it already is filled-in continue to find
2885
while(config->url_out && (config->url_out->flags&GETOUT_OUTFILE))
2886
config->url_out = config->url_out->next;
2889
/* now there might or might not be an available node to fill in! */
2893
url = config->url_out;
2895
/* there was no free node, create one! */
2896
url=new_getout(config);
2899
/* fill in the outfile */
2901
GetStr(&url->outfile, nextarg);
2902
url->flags &= ~GETOUT_USEREMOTE; /* switch off */
2875
/* now there might or might not be an available node to fill in! */
2879
url = config->url_out;
2881
/* there was no free node, create one! */
2882
url=new_getout(config);
2885
/* fill in the outfile */
2887
GetStr(&url->outfile, nextarg);
2905
url->outfile=NULL; /* leave it */
2907
url->flags |= GETOUT_USEREMOTE; /* switch on */
2888
2909
url->flags &= ~GETOUT_USEREMOTE; /* switch off */
2891
url->outfile=NULL; /* leave it */
2893
url->flags |= GETOUT_USEREMOTE; /* switch on */
2895
url->flags &= ~GETOUT_USEREMOTE; /* switch off */
2897
url->flags |= GETOUT_OUTFILE;
2911
url->flags |= GETOUT_OUTFILE;
2902
2916
/* This makes the FTP sessions use PORT instead of PASV */
2903
2917
/* use <eth0> or <192.168.10.10> style addresses. Anything except
2904
2918
this will make us try to get the "default" address.
2905
2919
NOTE: this is a changed behaviour since the released 4.1!
2907
2921
GetStr(&config->ftpport, nextarg);
5570
5600
errorbuffer[0]? errorbuffer:
5571
5601
curl_easy_strerror((CURLcode)res));
5572
5602
if(CURLE_SSL_CACERT == res) {
5573
#define CURL_CA_CERT_ERRORMSG1 \
5574
"More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
5575
"curl performs SSL certificate verification by default, using a \"bundle\"\n" \
5576
" of Certificate Authority (CA) public keys (CA certs). If the default\n" \
5577
" bundle file isn't adequate, you can specify an alternate file\n" \
5578
" using the --cacert option.\n"
5603
#define CURL_CA_CERT_ERRORMSG1 \
5604
"More details here: http://curl.haxx.se/docs/sslcerts.html\n\n" \
5605
"curl performs SSL certificate verification by default, using a \"bundle\"\n" \
5606
" of Certificate Authority (CA) public keys (CA certs). If the default\n" \
5607
" bundle file isn't adequate, you can specify an alternate file\n" \
5608
" using the --cacert option.\n"
5580
#define CURL_CA_CERT_ERRORMSG2 \
5581
"If this HTTPS server uses a certificate signed by a CA represented in\n" \
5582
" the bundle, the certificate verification probably failed due to a\n" \
5583
" problem with the certificate (it might be expired, or the name might\n" \
5584
" not match the domain name in the URL).\n" \
5585
"If you'd like to turn off curl's verification of the certificate, use\n" \
5586
" the -k (or --insecure) option.\n"
5610
#define CURL_CA_CERT_ERRORMSG2 \
5611
"If this HTTPS server uses a certificate signed by a CA represented in\n" \
5612
" the bundle, the certificate verification probably failed due to a\n" \
5613
" problem with the certificate (it might be expired, or the name might\n" \
5614
" not match the domain name in the URL).\n" \
5615
"If you'd like to turn off curl's verification of the certificate, use\n" \
5616
" the -k (or --insecure) option.\n"
5588
5618
fprintf(config->errors, "%s%s",
5589
5619
CURL_CA_CERT_ERRORMSG1,
5937
5967
size_t len = sizeof (illegal_chars_dos) - 1;
5939
5969
/* Support for Windows 9X VFAT systems, when available. */
5940
if (_use_lfn (file_name)) {
5970
if(_use_lfn (file_name)) {
5941
5971
illegal_aliens = illegal_chars_w95;
5942
5972
len -= (illegal_chars_w95 - illegal_chars_dos);
5945
5975
/* Get past the drive letter, if any. */
5946
if (s[0] >= 'A' && s[0] <= 'z' && s[1] == ':') {
5976
if(s[0] >= 'A' && s[0] <= 'z' && s[1] == ':') {
5951
for (idx = 0, dot_idx = -1; *s && d < dlimit; s++, d++) {
5952
if (memchr (illegal_aliens, *s, len)) {
5981
for(idx = 0, dot_idx = -1; *s && d < dlimit; s++, d++) {
5982
if(memchr (illegal_aliens, *s, len)) {
5953
5983
/* Dots are special: DOS doesn't allow them as the leading character,
5954
5984
and a file name cannot have more than a single dot. We leave the
5955
5985
first non-leading dot alone, unless it comes too close to the
5956
5986
beginning of the name: we want sh.lex.c to become sh_lex.c, not
5959
if (idx == 0 && (s[1] == '/' || (s[1] == '.' && s[2] == '/'))) {
5989
if(idx == 0 && (s[1] == '/' || (s[1] == '.' && s[2] == '/'))) {
5960
5990
/* Copy "./" and "../" verbatim. */
5968
else if (dot_idx >= 0) {
5969
if (dot_idx < 5) { /* 5 is a heuristic ad-hoc'ery */
5998
else if(dot_idx >= 0) {
5999
if(dot_idx < 5) { /* 5 is a heuristic ad-hoc'ery */
5970
6000
d[dot_idx - idx] = '_'; /* replace previous dot */