maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [1/2] maven-scm git commit: fixes #44 [SCM-817] Jgit provider exposes password if it contains special characters
Date Wed, 25 May 2016 11:28:59 GMT
Repository: maven-scm
Updated Branches:
  refs/heads/master 9f30e46c6 -> 355b84ec5


fixes #44 [SCM-817] Jgit provider exposes password if it contains special characters

Signed-off-by: olivier lamy <olamy@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/1c0bb9e8
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/1c0bb9e8
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/1c0bb9e8

Branch: refs/heads/master
Commit: 1c0bb9e8ea9d9bf0ecfad18bfea65baf175968ae
Parents: 9f30e46
Author: olivier lamy <olamy@apache.org>
Authored: Wed May 25 21:27:51 2016 +1000
Committer: olivier lamy <olamy@apache.org>
Committed: Wed May 25 21:27:51 2016 +1000

----------------------------------------------------------------------
 .../maven/scm/provider/git/jgit/command/JGitUtils.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/1c0bb9e8/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
----------------------------------------------------------------------
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
index f22a139..dc79802 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitUtils.java
@@ -62,7 +62,9 @@ import org.eclipse.jgit.util.io.DisabledOutputStream;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
@@ -131,6 +133,17 @@ public class JGitUtils
         // make sure we do not log any passwords to the output
         String password =
             StringUtils.isNotBlank( repository.getPassword() ) ? repository.getPassword().trim()
: "no-pwd-defined";
+        // if password contains special characters it won't match below.
+        // Try encoding before match. (Passwords without will be unaffected)
+        try
+        {
+            password = URLEncoder.encode( password, "UTF-8" );
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            // UTF-8 should be valid
+            e.printStackTrace();
+        }
         logger.info( "fetch url: " + repository.getFetchUrl().replace( password, "******"
) );
         logger.info( "push url: " + repository.getPushUrl().replace( password, "******" )
);
         return getCredentials( repository );


Mime
View raw message