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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michal Nazarewicz <mpn@xxxxxxxxxx> writes:

> +=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.

> +sub credential_read {
> +	my ($self, $reader) = _maybe_self(@_);
> +	my %credential;
> +	while (<$reader>) {
> +		chomp;
> +		if ($_ eq '') {
> +			last;
> +		} elsif (!/^([^=]+)=(.*)$/) {

Good.

> +	# 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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]