commit | c4ef993fa5e8578641d6447c831ace13743dd5de | [log] [tgz] |
---|---|---|
author | Mike Frysinger <vapier@google.com> | Thu Jul 02 02:35:17 2020 -0400 |
committer | Mike Frysinger <vapier@google.com> | Thu Jul 02 02:35:17 2020 -0400 |
tree | ead20066ff160756712671e78f5871cdef57cc35 | |
parent | 47b783ea75036664dd591d2d3f1bcd06b68cdd5e [diff] |
avoid quoting on basic strings Shells don't need quoting for many basic characters, so make the logic a bit smarter by omitting the quotes when the string consists entirely of those "safe" characters. Bug: Issue 10021 Change-Id: I8410572007d5700ce0fd7642e3322c0dc89e31cc
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/QuoteUtil.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/QuoteUtil.java index e3c73f8..a08cbae 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/QuoteUtil.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/QuoteUtil.java
@@ -19,6 +19,11 @@ private QuoteUtil() {} public static String quote(String string) { - return "\"" + string + "\""; + // Avoid quotes if the chars are entirely "safe". + if (string.matches("^[a-zA-Z0-9@_.:/-]+$")) { + return string; + } else { + return "\"" + string + "\""; + } } }