Subject: Bug: git svn sends password + "\n" on windows

From: [email-masked]
Date: Fri, 06 Jul 2012 09:39:08 +0200

Hi,

please go easy on me, this is my first bug report. I hope this is the right
place to post.

Problem: When using SshAskPass (from TortoiseGit, on Windows), git svn clone
fails with 

| git.exe svn clone "http://xxx/svn/Project"  "D:\Project"
| 
| Initialized empty Git repository in d:/Project/.git/
| Authentication realm: <http://xxx:80> Subversion Repository
| Authentication realm: <http://dew132:80> Subversion Repository
| Username: Use of uninitialized value in chomp at C:\Program Files\Git/libexec/git-core\git-svn line 4417.
| 0 [main] perl.exe" 7200 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
| 433 [main] perl.exe" 7200 open_stackdumpfile: Dumping stack trace to perl.exe.stackdump
| 
| git did not exit cleanly (exit code -1)

I have verified that the git svn client sends the base64 encoded string
"password" + "\n" as http header:
| Authorization: Basic dGVzdAo=
(Which should decode to "test\n". I had to replace my password with a manual
encoded version to show to you.)

I think there is a bug/issue in perl/Git/SVN/Prompt.pm. On windows only "\r" of
"\r\n" gets removed after calling GIT_ASKPASS. I have changed, 

diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index 3a6f8af..8f49457 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -124,7 +124,7 @@ sub _read_password {
 	if (exists $ENV{GIT_ASKPASS}) {
 		open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt);
 		$password = <PH>;
-		$password =~ s/[\012\015]//; # \n\r
+		$password =~ s/[\012\015][\012\015]?//; # \n\r
 		close(PH);
 	} else {
 		print STDERR $prompt;

and the clone worked, but think one should chomp (as sub username does):

diff --git a/perl/Git/SVN/Prompt.pm b/perl/Git/SVN/Prompt.pm
index 3a6f8af..30b6256 100644
--- a/perl/Git/SVN/Prompt.pm
+++ b/perl/Git/SVN/Prompt.pm
@@ -123,8 +123,7 @@ sub _read_password {
 	my $password = '';
 	if (exists $ENV{GIT_ASKPASS}) {
 		open(PH, "-|", $ENV{GIT_ASKPASS}, $prompt);
-		$password = <PH>;
-		$password =~ s/[\012\015]//; # \n\r
+		chomp($password = <PH>);
 		close(PH);
 	} else {
 		print STDERR $prompt;

Unfortunately I could not test the 2nd version, because somehow git saves the
successful credentials and I have not researched/found out, how to reset that
information yet.

Thanks for your consideration
Micha Wiedenmann

Versions:
TortoiseGit 1.7.10.0 
git version 1.7.10.msysgit.1