Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2015-09-26 04:35:50 -0400
committerAndrey Loskutov2015-09-26 12:48:51 -0400
commit64efb89f4cf9a2c1b87803dd261688f48a421bde (patch)
tree39ee6fc6b6a5dc1456555ea4b5e33d9af5e774ec
parent1ab13aeff5efd1b879411533d463b4fa77778fa9 (diff)
downloadegit-64efb89f4cf9a2c1b87803dd261688f48a421bde.tar.gz
egit-64efb89f4cf9a2c1b87803dd261688f48a421bde.tar.xz
egit-64efb89f4cf9a2c1b87803dd261688f48a421bde.zip
GitURI should not try to parse "path" part if it is missing in the URI
Bug: 478464 Change-Id: I4c376c1d8df3a90ca5d59d8cfa36d2dbecab9772 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitURITest.java8
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/GitURI.java7
2 files changed, 14 insertions, 1 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitURITest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitURITest.java
index db560774e..0d3df1a6d 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitURITest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/GitURITest.java
@@ -40,6 +40,14 @@ public class GitURITest {
@SuppressWarnings("unused")
@Test(expected = IllegalArgumentException.class)
+ public void testInvalidScmUriWithoutPath() throws Exception {
+ new GitURI(URI
+ .create("scm:git:git://git.eclipse.org/gitroot/cdo/cdo.git"));
+ // expected IAE, it doesn't contain semicolon and path part
+ }
+
+ @SuppressWarnings("unused")
+ @Test(expected = IllegalArgumentException.class)
public void testInvalidScmUriForCVS() throws Exception {
new GitURI(URI.create("scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.compare"));
// expected IAE, it's a CVS SCM URL
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/GitURI.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/GitURI.java
index 525efbe22..2d21f4058 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/GitURI.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/GitURI.java
@@ -56,8 +56,13 @@ public class GitURI {
try {
if (SCHEME_SCM.equals(uri.getScheme())) {
final String ssp = uri.getSchemeSpecificPart();
+ int indexOfSemicolon = ssp.indexOf(';');
+ if (indexOfSemicolon < 0) {
+ throw new IllegalArgumentException(
+ NLS.bind(CoreText.GitURI_InvalidSCMURL,
+ new String[] { uri.toString() }));
+ }
if (ssp.startsWith(SCHEME_GIT)) {
- int indexOfSemicolon = ssp.indexOf(';');
URIish r = new URIish(ssp.substring(
SCHEME_GIT.length() + 1, indexOfSemicolon));
IPath p = null;

Back to the top