netrc: ignore unknown lines (do not die)

Contrary to the documentation on credential helpers, as well as the help
text for git-credential-netrc itself, this helper will `die` when
presented with an unknown property/attribute/token.

Correct the behaviour here by skipping and ignoring any tokens that are
unknown. This means all helpers in the tree are consistent and ignore
any unknown credential properties/attributes.

Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Matthew John Cheetham 2022-09-22 16:59:33 +00:00 committed by Junio C Hamano
parent d695804983
commit 6ea87d97af

View File

@ -356,7 +356,10 @@ sub read_credential_data_from_stdin {
next unless m/^([^=]+)=(.+)/;
my ($token, $value) = ($1, $2);
die "Unknown search token $token" unless exists $q{$token};
# skip any unknown tokens
next unless exists $q{$token};
$q{$token} = $value;
log_debug("We were given search token $token and value $value");
}