mirror of
https://github.com/curl/curl.git
synced 2026-07-27 23:23:07 +03:00
noproxy: support for space-separated names is deprecated
To be removed in July 2024. Assisted-by: Michael Osipov Fixes #10209 Closes #10215
This commit is contained in:
parent
bb393e521f
commit
7ad8a7ba9e
5 changed files with 88 additions and 44 deletions
|
|
@ -46,6 +46,7 @@ struct noproxy {
|
|||
const char *a;
|
||||
const char *n;
|
||||
bool match;
|
||||
bool space; /* space separated */
|
||||
};
|
||||
|
||||
UNITTEST_START
|
||||
|
|
@ -77,50 +78,52 @@ UNITTEST_START
|
|||
{ NULL, NULL, 0, FALSE} /* end marker */
|
||||
};
|
||||
struct noproxy list[]= {
|
||||
{ "www.example.com", "localhost,.example.com,.example.de", TRUE},
|
||||
{ "www.example.com.", "localhost,.example.com,.example.de", TRUE},
|
||||
{ "example.com", "localhost,.example.com,.example.de", TRUE},
|
||||
{ "example.com.", "localhost,.example.com,.example.de", TRUE},
|
||||
{ "www.example.com", "localhost,.example.com.,.example.de", TRUE},
|
||||
{ "www.example.com", "localhost,www.example.com.,.example.de", TRUE},
|
||||
{ "example.com", "localhost,example.com,.example.de", TRUE},
|
||||
{ "example.com.", "localhost,example.com,.example.de", TRUE},
|
||||
{ "nexample.com", "localhost,example.com,.example.de", FALSE},
|
||||
{ "www.example.com", "localhost,example.com,.example.de", TRUE},
|
||||
{ "127.0.0.1", "127.0.0.1,localhost", TRUE},
|
||||
{ "127.0.0.1", "127.0.0.1,localhost,", TRUE},
|
||||
{ "127.0.0.1", "127.0.0.1/8,localhost,", TRUE},
|
||||
{ "127.0.0.1", "127.0.0.1/28,localhost,", TRUE},
|
||||
{ "127.0.0.1", "127.0.0.1/31,localhost,", TRUE},
|
||||
{ "127.0.0.1", "localhost,127.0.0.1", TRUE},
|
||||
{ "www.example.com", "localhost .example.com .example.de", TRUE, TRUE},
|
||||
{ "www.example.com", "localhost,.example.com,.example.de", TRUE, FALSE},
|
||||
{ "www.example.com.", "localhost,.example.com,.example.de", TRUE, FALSE},
|
||||
{ "example.com", "localhost,.example.com,.example.de", TRUE, FALSE},
|
||||
{ "example.com.", "localhost,.example.com,.example.de", TRUE, FALSE},
|
||||
{ "www.example.com", "localhost,.example.com.,.example.de", TRUE, FALSE},
|
||||
{ "www.example.com", "localhost,www.example.com.,.example.de",
|
||||
TRUE, FALSE},
|
||||
{ "example.com", "localhost,example.com,.example.de", TRUE, FALSE},
|
||||
{ "example.com.", "localhost,example.com,.example.de", TRUE, FALSE},
|
||||
{ "nexample.com", "localhost,example.com,.example.de", FALSE, FALSE},
|
||||
{ "www.example.com", "localhost,example.com,.example.de", TRUE, FALSE},
|
||||
{ "127.0.0.1", "127.0.0.1,localhost", TRUE, FALSE},
|
||||
{ "127.0.0.1", "127.0.0.1,localhost,", TRUE, FALSE},
|
||||
{ "127.0.0.1", "127.0.0.1/8,localhost,", TRUE, FALSE},
|
||||
{ "127.0.0.1", "127.0.0.1/28,localhost,", TRUE, FALSE},
|
||||
{ "127.0.0.1", "127.0.0.1/31,localhost,", TRUE, FALSE},
|
||||
{ "127.0.0.1", "localhost,127.0.0.1", TRUE, FALSE},
|
||||
{ "127.0.0.1", "localhost,127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1."
|
||||
"127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127."
|
||||
"0.0.1.127.0.0.1.127.0.0." /* 128 bytes "address" */, FALSE},
|
||||
"0.0.1.127.0.0.1.127.0.0." /* 128 bytes "address" */, FALSE, FALSE},
|
||||
{ "127.0.0.1", "localhost,127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1."
|
||||
"127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127."
|
||||
"0.0.1.127.0.0.1.127.0.0" /* 127 bytes "address" */, FALSE},
|
||||
{ "localhost", "localhost,127.0.0.1", TRUE},
|
||||
{ "localhost", "127.0.0.1,localhost", TRUE},
|
||||
{ "foobar", "barfoo", FALSE},
|
||||
{ "foobar", "foobar", TRUE},
|
||||
{ "192.168.0.1", "foobar", FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0/16", TRUE},
|
||||
{ "192.168.0.1", "192.168.0.0/24", TRUE},
|
||||
{ "192.168.0.1", "192.168.0.0/32", FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0", FALSE},
|
||||
{ "192.168.1.1", "192.168.0.0/24", FALSE},
|
||||
{ "192.168.1.1", "foo, bar, 192.168.0.0/24", FALSE},
|
||||
{ "192.168.1.1", "foo, bar, 192.168.0.0/16", TRUE},
|
||||
{ "[::1]", "foo, bar, 192.168.0.0/16", FALSE},
|
||||
{ "[::1]", "foo, bar, ::1/64", TRUE},
|
||||
{ "bar", "foo, bar, ::1/64", TRUE},
|
||||
{ "BAr", "foo, bar, ::1/64", TRUE},
|
||||
{ "BAr", "foo,,,,, bar, ::1/64", TRUE},
|
||||
{ "www.example.com", "foo, .example.com", TRUE},
|
||||
{ "www.example.com", "www2.example.com, .example.net", FALSE},
|
||||
{ "example.com", ".example.com, .example.net", TRUE},
|
||||
{ "nonexample.com", ".example.com, .example.net", FALSE},
|
||||
{ NULL, NULL, FALSE}
|
||||
"0.0.1.127.0.0.1.127.0.0" /* 127 bytes "address" */, FALSE, FALSE},
|
||||
{ "localhost", "localhost,127.0.0.1", TRUE, FALSE},
|
||||
{ "localhost", "127.0.0.1,localhost", TRUE, FALSE},
|
||||
{ "foobar", "barfoo", FALSE, FALSE},
|
||||
{ "foobar", "foobar", TRUE, FALSE},
|
||||
{ "192.168.0.1", "foobar", FALSE, FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0/16", TRUE, FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0/24", TRUE, FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0/32", FALSE, FALSE},
|
||||
{ "192.168.0.1", "192.168.0.0", FALSE, FALSE},
|
||||
{ "192.168.1.1", "192.168.0.0/24", FALSE, FALSE},
|
||||
{ "192.168.1.1", "foo, bar, 192.168.0.0/24", FALSE, FALSE},
|
||||
{ "192.168.1.1", "foo, bar, 192.168.0.0/16", TRUE, FALSE},
|
||||
{ "[::1]", "foo, bar, 192.168.0.0/16", FALSE, FALSE},
|
||||
{ "[::1]", "foo, bar, ::1/64", TRUE, FALSE},
|
||||
{ "bar", "foo, bar, ::1/64", TRUE, FALSE},
|
||||
{ "BAr", "foo, bar, ::1/64", TRUE, FALSE},
|
||||
{ "BAr", "foo,,,,, bar, ::1/64", TRUE, FALSE},
|
||||
{ "www.example.com", "foo, .example.com", TRUE, FALSE},
|
||||
{ "www.example.com", "www2.example.com, .example.net", FALSE, FALSE},
|
||||
{ "example.com", ".example.com, .example.net", TRUE, FALSE},
|
||||
{ "nonexample.com", ".example.com, .example.net", FALSE, FALSE},
|
||||
{ NULL, NULL, FALSE, FALSE}
|
||||
};
|
||||
for(i = 0; list4[i].a; i++) {
|
||||
bool match = Curl_cidr4_match(list4[i].a, list4[i].n, list4[i].bits);
|
||||
|
|
@ -141,13 +144,19 @@ UNITTEST_START
|
|||
}
|
||||
}
|
||||
for(i = 0; list[i].a; i++) {
|
||||
bool match = Curl_check_noproxy(list[i].a, list[i].n);
|
||||
bool spacesep = FALSE;
|
||||
bool match = Curl_check_noproxy(list[i].a, list[i].n, &spacesep);
|
||||
if(match != list[i].match) {
|
||||
fprintf(stderr, "%s in %s should %smatch\n",
|
||||
list[i].a, list[i].n,
|
||||
list[i].match ? "": "not ");
|
||||
err++;
|
||||
}
|
||||
if(spacesep != list[i].space) {
|
||||
fprintf(stderr, "%s is claimed to be %sspace separated\n",
|
||||
list[i].n, list[i].space?"":"NOT ");
|
||||
err++;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue