aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris West (Faux)2010-09-08 20:15:27 (EDT)
committerChris West (Faux)2010-09-10 16:04:01 (EDT)
commit2a523594542a544a187de006c315ead2c7e7e908 (patch)
treeca99fb171e170316f37c52a8d325d93cb8a10585
parent0e8ef778407ced21048cf7e43b4383b23f3ccdc5 (diff)
downloadjgit-2a523594542a544a187de006c315ead2c7e7e908.zip
jgit-2a523594542a544a187de006c315ead2c7e7e908.tar.gz
jgit-2a523594542a544a187de006c315ead2c7e7e908.tar.bz2
Allow ../relative paths in remotesrefs/changes/75/1575/2
git allows remotes to be relative paths, but the regex validating urls wouldn't accept anything starting with "..". Other functionality works fine with these paths. Bug: 311300 Change-Id: Ib74de0450a1c602b22884e19d994ce2f52634c77
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java7
2 files changed, 16 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
index ff8c9a6..6aef874 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
@@ -83,6 +83,16 @@ public class URIishTest extends TestCase {
assertEquals(u, new URIish(str));
}
+ public void testRelativePath() throws Exception {
+ final String str = "../../foo/bar";
+ URIish u = new URIish(str);
+ assertNull(u.getScheme());
+ assertFalse(u.isRemote());
+ assertEquals(str, u.getPath());
+ assertEquals(str, u.toString());
+ assertEquals(u, new URIish(str));
+ }
+
public void testUNC() throws Exception {
final String str = "\\\\some\\place";
URIish u = new URIish(str);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
index 3f53328..44160c0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -64,7 +64,12 @@ public class URIish implements Serializable {
private static final long serialVersionUID = 1L;
private static final Pattern FULL_URI = Pattern
- .compile("^(?:([a-z][a-z0-9+-]+)://(?:([^/]+?)(?::([^/]+?))?@)?(?:([^/]+?))?(?::(\\d+))?)?((?:[A-Za-z]:)?/.+)$");
+ .compile("^(?:([a-z][a-z0-9+-]+)://" // optional http://
+ + "(?:([^/]+?)(?::([^/]+?))?@)?" // optional user:password@
+ + "(?:([^/]+?))?(?::(\\d+))?)?" // optional example.com:1337
+ + "((?:[A-Za-z]:)?" // optional drive-letter:
+ + "(?:\\.\\.)?" // optionally a relative path
+ +"/.+)$"); // /anything
private static final Pattern SCP_URI = Pattern
.compile("^(?:([^@]+?)@)?([^:]+?):(.+)$");