aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2018-09-16 05:08:15 -0400
committerMichael Keppler2018-09-16 05:08:15 -0400
commit54cf1194191ee258bb0bc24f0cf16ad5c966e941 (patch)
tree9d1f341bab446ad47ed425c3594642a6ac4c20c6
parent5d14d64e685dc3e3b2213742a2e48e5354597fb6 (diff)
downloadegit-54cf1194191ee258bb0bc24f0cf16ad5c966e941.tar.gz
egit-54cf1194191ee258bb0bc24f0cf16ad5c966e941.tar.xz
egit-54cf1194191ee258bb0bc24f0cf16ad5c966e941.zip
StackOverflowError in RefSpecPanel.isValidRefExpression
Endless loop if the wildcard character is not at the last position. Avoid the recursion, check for single wildcard character only and simplify isValidRefName checking. Bug: 539046 Change-Id: I6f46cfbaeaf2da64ed020373e3783f914d3658bd Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
index f5a7b0990..4975f2d01 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/RefSpecPanel.java
@@ -145,13 +145,19 @@ public class RefSpecPanel {
}
private static boolean isValidRefExpression(final String s) {
- if (RefSpec.isWildcard(s)) {
- // replace wildcard with some legal name just for checking
- return isValidRefExpression(s.substring(0, s.length() - 1) + 'X');
- } else
- return Repository.isValidRefName(s)
- || Repository.isValidRefName(Constants.R_HEADS + s)
- || Repository.isValidRefName(Constants.R_TAGS + s);
+ if (s == null) {
+ return false;
+ }
+ String spec = s;
+ int i = spec.indexOf('*');
+ if (i >= 0) {
+ if (spec.indexOf('*', i + 1) >= 0) {
+ return false; // Only one '*' allowed
+ }
+ // replace wildcard by arbitrary legal character for checking
+ spec = spec.replace('*', 'X');
+ }
+ return Repository.isValidRefName(Constants.R_HEADS + spec);
}
private static RefSpec setRefSpecSource(final RefSpec spec, final String src) {