netrc: 'default' with no credentials is not a match
Test 486 verifies. Reported-by: Yihang Zhou Closes #15908
This commit is contained in:
parent
abf8062449
commit
0e120c5b92
15
lib/netrc.c
15
lib/netrc.c
@ -316,11 +316,16 @@ static int parsenetrc(struct store_netrc *store,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
Curl_dyn_free(&token);
|
Curl_dyn_free(&token);
|
||||||
if(!retcode && !password && our_login) {
|
if(!retcode) {
|
||||||
/* success without a password, set a blank one */
|
if(!password && our_login) {
|
||||||
password = strdup("");
|
/* success without a password, set a blank one */
|
||||||
if(!password)
|
password = strdup("");
|
||||||
retcode = 1; /* out of memory */
|
if(!password)
|
||||||
|
retcode = 1; /* out of memory */
|
||||||
|
}
|
||||||
|
else if(!login && !password)
|
||||||
|
/* a default with no credentials */
|
||||||
|
retcode = NETRC_FILE_MISSING;
|
||||||
}
|
}
|
||||||
if(!retcode) {
|
if(!retcode) {
|
||||||
/* success */
|
/* success */
|
||||||
|
|||||||
@ -78,7 +78,7 @@ test444 test445 test446 test447 test448 test449 test450 test451 test452 \
|
|||||||
test453 test454 test455 test456 test457 test458 test459 test460 test461 \
|
test453 test454 test455 test456 test457 test458 test459 test460 test461 \
|
||||||
test462 test463 test467 test468 test469 test470 test471 test472 test473 \
|
test462 test463 test467 test468 test469 test470 test471 test472 test473 \
|
||||||
test474 test475 test476 test477 test478 test479 test480 test481 test482 \
|
test474 test475 test476 test477 test478 test479 test480 test481 test482 \
|
||||||
test483 test484 test485 \
|
test483 test484 test485 test486 \
|
||||||
test490 test491 test492 test493 test494 test495 test496 test497 test498 \
|
test490 test491 test492 test493 test494 test495 test496 test497 test498 \
|
||||||
test499 test500 test501 test502 test503 test504 test505 test506 test507 \
|
test499 test500 test501 test502 test503 test504 test505 test506 test507 \
|
||||||
test508 test509 test510 test511 test512 test513 test514 test515 test516 \
|
test508 test509 test510 test511 test512 test513 test514 test515 test516 \
|
||||||
|
|||||||
105
tests/data/test486
Normal file
105
tests/data/test486
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
netrc
|
||||||
|
HTTP
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data crlf="yes">
|
||||||
|
HTTP/1.1 301 Follow this you fool
|
||||||
|
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||||
|
ETag: "21025-dc7-39462498"
|
||||||
|
Accept-Ranges: bytes
|
||||||
|
Content-Length: 6
|
||||||
|
Connection: close
|
||||||
|
Location: http://b.com/%TESTNUMBER0002
|
||||||
|
|
||||||
|
-foo-
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<data2 crlf="yes">
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||||
|
ETag: "21025-dc7-39462498"
|
||||||
|
Accept-Ranges: bytes
|
||||||
|
Content-Length: 7
|
||||||
|
Connection: close
|
||||||
|
|
||||||
|
target
|
||||||
|
</data2>
|
||||||
|
|
||||||
|
<datacheck crlf="yes">
|
||||||
|
HTTP/1.1 301 Follow this you fool
|
||||||
|
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||||
|
ETag: "21025-dc7-39462498"
|
||||||
|
Accept-Ranges: bytes
|
||||||
|
Content-Length: 6
|
||||||
|
Connection: close
|
||||||
|
Location: http://b.com/%TESTNUMBER0002
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Date: Tue, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
|
||||||
|
ETag: "21025-dc7-39462498"
|
||||||
|
Accept-Ranges: bytes
|
||||||
|
Content-Length: 7
|
||||||
|
Connection: close
|
||||||
|
|
||||||
|
target
|
||||||
|
</datacheck>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
http
|
||||||
|
</server>
|
||||||
|
<features>
|
||||||
|
proxy
|
||||||
|
</features>
|
||||||
|
<name>
|
||||||
|
.netrc with redirect and "default" with no password or login
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
--netrc --netrc-file %LOGDIR/netrc%TESTNUMBER -L -x http://%HOSTIP:%HTTPPORT/ http://a.com/
|
||||||
|
</command>
|
||||||
|
<file name="%LOGDIR/netrc%TESTNUMBER" >
|
||||||
|
|
||||||
|
machine a.com
|
||||||
|
login alice
|
||||||
|
password alicespassword
|
||||||
|
|
||||||
|
default
|
||||||
|
|
||||||
|
</file>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
<verify>
|
||||||
|
<protocol>
|
||||||
|
GET http://a.com/ HTTP/1.1
|
||||||
|
Host: a.com
|
||||||
|
Authorization: Basic %b64[alice:alicespassword]b64%
|
||||||
|
User-Agent: curl/%VERSION
|
||||||
|
Accept: */*
|
||||||
|
Proxy-Connection: Keep-Alive
|
||||||
|
|
||||||
|
GET http://b.com/%TESTNUMBER0002 HTTP/1.1
|
||||||
|
Host: b.com
|
||||||
|
User-Agent: curl/%VERSION
|
||||||
|
Accept: */*
|
||||||
|
Proxy-Connection: Keep-Alive
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
||||||
Loading…
Reference in New Issue
Block a user