[hg] no need to stripe auth from log anymore since we neither store it nor send.
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 7 Apr 2011 13:35:45 +0000 (17:35 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Fri, 8 Apr 2011 10:22:21 +0000 (14:22 +0400)
plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java

index c9cdfee3fb7d40812cefd9e9b7d5dfa7be2aaf09..0c608f735cc6a2a08f96926767305f75288a7a6b 100644 (file)
@@ -29,9 +29,7 @@ import java.io.DataOutputStream;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.net.Socket;
-import java.net.URI;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -180,7 +178,7 @@ public final class HgCommandExecutor {
   // logging to the Version Control console (without extensions and configs)
   private void log(String operation, List<String> arguments, HgCommandResult result) {
     final String executable = mySettings.isRunViaBash() ? "bash -c " + HgVcs.HG_EXECUTABLE_FILE_NAME : HgVcs.HG_EXECUTABLE_FILE_NAME;
-    final String cmdString = String.format("%s %s %s", executable, operation, StringUtils.join(maskAuthInfoFromUrl(arguments), " "));
+    final String cmdString = String.format("%s %s %s", executable, operation, StringUtils.join(arguments, " "));
 
     // log command
     LOG.info(cmdString);
@@ -201,32 +199,6 @@ public final class HgCommandExecutor {
     }
   }
 
-  /**
-   * Strips possible authentication information from arguments passed to the command line
-   * to prevent private information appear in the VCS console or logs.
-   * @param arguments command line arguments.
-   * @return command line arguments which don't contain authentication information.
-   */
-  private static List<String> maskAuthInfoFromUrl(List<String> arguments) {
-    if (arguments == null || arguments.isEmpty()) {
-      return arguments;
-    }
-    final List<String> newArgs = new ArrayList<String>(arguments.size());
-    for (String arg : arguments) {
-      if (!arg.contains("@")) { // simple filter
-        newArgs.add(arg);
-      } else {
-        try {
-          final URI uri = new URI(arg); // parsing via URI methods, exception means it's not an URI
-          newArgs.add(uri.toString().replace(uri.getUserInfo(), "<username>:<password>"));
-        } catch (Throwable e) {
-          newArgs.add(arg);
-        }
-      }
-    }
-    return newArgs;
-  }
-
   private void showError(Exception e) {
     final HgVcs vcs = HgVcs.getInstance(myProject);
     if (vcs == null) { return; }