git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv4 5/6] Git.pm: add interface for git credential command

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Feb 27, 2013, 14:18 UTC
Message-ID
<vpqppzl4z7d.fsf@grenoble-inp.fr>
In-Reply-To
<e5834c9b5ccb66a88b64b3d07982ad41205fb97e.1360677646.git.mina86@mina86.com>
Michal Nazarewicz <mpn@google.com> writes:
Show 6 quoted lines
> +=item credential_read( FILEHANDLE )
> +
> +Reads credential key-value pairs from C<FILEHANDLE>.  Reading stops at EOF or
> +when an empty line is encountered.  Each line must be of the form C<key=value>
> +with a non-empty key.  Function returns hash with all read values.  Any white
> +space (other then new-line character) is preserved.
Typo: other then -> than.
Show 8 quoted lines
> +sub credential_read {
> +	my ($self, $reader) = _maybe_self(@_);
> +	my %credential;
> +	while (<$reader>) {
> +		chomp;
> +		if ($_ eq '') {
> +			last;
> +		} elsif (!/^([^=]+)=(.*)$/) {
Good.
Show 10 quoted lines
> +	# Check if $credential is valid prior to writing anything
> +	while (($key, $value) = each %$credential) {
> +		if (!defined $key || !length $key) {
> +			throw Error::Simple("credential key empty or undefined");
> +		} elsif ($key =~ /[=\n\0]/) {
> +			throw Error::Simple("credential key contains invalid characters: $key");
> +		} elsif (defined $value && $value =~ /[\n\0]/) {
> +			throw Error::Simple("credential value for key=$key contains invalid characters: $value");
> +		}
> +	}
Good.

These checks seem to address all the points raised during discussion about when the API should reject values.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Michal NazarewiczNext: Michal Nazarewicz
Message 16 of 22 in “[PATCHv4 0/6] git-credential support in git-send-email”
  1. Michal NazarewiczFeb 12, 2013
  2. 1/6 Git.pm: allow command_close_bidi_pipe to be called as methodMichal Nazarewicz, Feb 12, 2013
  3. 2/6 Git.pm: fix example in command_close_bidi_pipe documentationMichal Nazarewicz, Feb 12, 2013
  4. 3/6 Git.pm: refactor command_close_bidi_pipe to use _cmd_closeMichal Nazarewicz, Feb 12, 2013
  5. Junio C HamanoFeb 12, 2013
  6. Jeff KingFeb 12, 2013
  7. Michal NazarewiczFeb 12, 2013
  8. Junio C HamanoFeb 12, 2013
  9. 4/6 Git.pm: allow pipes to be closed prior to calling command_close_bidi_pipeMichal Nazarewicz, Feb 12, 2013
  10. Jeff KingFeb 12, 2013
  11. Michal NazarewiczFeb 12, 2013
  12. Junio C HamanoFeb 12, 2013
  13. Jeff KingFeb 12, 2013
  14. Michal NazarewiczFeb 12, 2013
  15. 5/6 Git.pm: add interface for git credential commandMichal Nazarewicz, Feb 12, 2013
  16. Matthieu MoyFeb 27, 2013
  17. 6/6 git-send-email: use git credential to obtain passwordMichal Nazarewicz, Feb 12, 2013
  18. Matthieu MoyFeb 27, 2013
  19. Junio C HamanoFeb 27, 2013
  20. Michal NazarewiczFeb 27, 2013
  21. Matthieu MoyFeb 27, 2013
  22. Junio C HamanoFeb 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.