michael-o commented on code in PR #237:
URL: https://github.com/apache/maven-scm/pull/237#discussion_r2022619950


##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/repository/GitScmProviderRepository.java:
##########
@@ -246,21 +259,11 @@ private String getUrl(RepositoryUrl repoUrl) {
             }
 
             if (userName != null && userName.length() > 0) {
-                String userInfo = userName;
+                String userInfo = GitUtil.encodeURIComponent(userName);
                 if (password != null && password.length() > 0) {
-                    userInfo += ":" + password;
+                    userInfo += ":" + GitUtil.encodeURIComponent(password);

Review Comment:
   This is a separate improvement, right? If so, can you separate it out? I'd 
merge it separately.



##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-git-commons/src/main/java/org/apache/maven/scm/provider/git/util/GitUtil.java:
##########
@@ -77,4 +89,52 @@ public static void setSettingsDirectory(File directory) {
     public static File getSettingsFile() {
         return new File(settingsDirectory, GIT_SETTINGS_FILENAME);
     }
+
+    /**
+     * Encodes the passed String as UTF-8 using an algorithm that's
+     * compatible with JavaScript's <code>encodeURIComponent</code> function.
+     * Returns <code>null</code> if the String is <code>null</code>.
+     * See 
http://stackoverflow.com/questions/607176/java-equivalent-to-javascripts-encodeuricomponent-that-produces-identical-output
+     * 
+     * @author John Topley
+     * @param s The String to be encoded
+     * @return the encoded String
+     */
+    public static String encodeURIComponent(String s) {
+        String result = s;
+        if (s != null) {
+            try {
+                result = URLEncoder.encode(s, StandardCharsets.UTF_8.name()) 
// nl

Review Comment:
   URLEncoder is not a URI encoder. This is for forms, not for URLs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to