summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2011-03-27 22:42:57 +0200
committerRobin Rosenberg <robin.rosenberg@dewire.com>2011-03-28 07:41:48 +0200
commitd1718a34d3f2c258a166b563c477b268ac8002ed (patch)
tree4fbb817a016467b529db00dc99dba7c6932b97a2
parent73602c448cde4e69ca59476d2b1c49ef91367591 (diff)
downloadjgit-d1718a34d3f2c258a166b563c477b268ac8002ed.tar.gz
jgit-d1718a34d3f2c258a166b563c477b268ac8002ed.zip
Do not normalize URIishes
We used to normalize URI's since it seems simple. This however causes inconsistencies to the user and to out tests. Just pass backslashes through and make sure our parser can handle them. Bug: 341062 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Change-Id: I2c8e917a086faabcd8749160c2acc9dd05a42838
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java23
2 files changed, 15 insertions, 16 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 edcab8a92d..c86869d088 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
@@ -90,8 +90,8 @@ public class URIishTest {
URIish u = new URIish(str);
assertNull(u.getScheme());
assertFalse(u.isRemote());
- assertEquals("D:/m y", u.getPath());
- assertEquals("D:/m y", u.toString());
+ assertEquals("D:\\m y", u.getPath());
+ assertEquals("D:\\m y", u.toString());
assertEquals(u, new URIish(str));
}
@@ -112,8 +112,8 @@ public class URIishTest {
URIish u = new URIish(str);
assertNull(u.getScheme());
assertFalse(u.isRemote());
- assertEquals("//some/place", u.getPath());
- assertEquals("//some/place", u.toString());
+ assertEquals("\\\\some\\place", u.getPath());
+ assertEquals("\\\\some\\place", u.toString());
assertEquals(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 bc24516a65..8c7bedc6fc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java
@@ -75,13 +75,13 @@ public class URIish implements Serializable {
* capturing groups: the first containing the user and the second containing
* the password
*/
- private static final String OPT_USER_PWD_P = "(?:([^/:@]+)(?::([^/]+))?@)?";
+ private static final String OPT_USER_PWD_P = "(?:([^\\\\/:@]+)(?::([^\\\\/]+))?@)?";
/**
* Part of a pattern which matches the host part of URIs. Defines one
* capturing group containing the host name.
*/
- private static final String HOST_P = "([^/:]+)";
+ private static final String HOST_P = "([^\\\\/:]+)";
/**
* Part of a pattern which matches the optional port part of URIs. Defines
@@ -93,7 +93,7 @@ public class URIish implements Serializable {
* Part of a pattern which matches the ~username part (e.g. /~root in
* git://host.xyz/~root/a.git) of URIs. Defines no capturing group.
*/
- private static final String USER_HOME_P = "(?:/~(?:[^/]+))";
+ private static final String USER_HOME_P = "(?:/~(?:[^\\\\/]+))";
/**
* Part of a pattern which matches the optional drive letter in paths (e.g.
@@ -105,13 +105,13 @@ public class URIish implements Serializable {
* Part of a pattern which matches a relative path. Relative paths don't
* start with slash or drive letters. Defines no capturing group.
*/
- private static final String RELATIVE_PATH_P = "(?:(?:[^/]+/)*[^/]+/?)";
+ private static final String RELATIVE_PATH_P = "(?:(?:[^\\\\/]+[\\\\/])*[^\\\\/]+[\\\\/]?)";
/**
* Part of a pattern which matches a relative or absolute path. Defines no
* capturing group.
*/
- private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "/?"
+ private static final String PATH_P = "(" + OPT_DRIVE_LETTER_P + "[\\\\/]?"
+ RELATIVE_PATH_P + ")";
private static final long serialVersionUID = 1L;
@@ -129,7 +129,7 @@ public class URIish implements Serializable {
+ OPT_PORT_P //
+ "(" // open a catpuring group the the user-home-dir part
+ (USER_HOME_P + "?") //
- + "/)" //
+ + "[\\\\/])" //
+ ")?" // close the optional group containing hostname
+ "(.+)?" //
+ "$");
@@ -139,7 +139,7 @@ public class URIish implements Serializable {
* path (maybe even containing windows drive-letters) or a relative path.
*/
private static final Pattern LOCAL_FILE = Pattern.compile("^" //
- + "(/?" + PATH_P + ")" //
+ + "([\\\\/]?" + PATH_P + ")" //
+ "$");
/**
@@ -148,7 +148,7 @@ public class URIish implements Serializable {
* separator, but java.io.File.toURI() constructs those URIs.
*/
private static final Pattern SINGLE_SLASH_FILE_URI = Pattern.compile("^" //
- + "(file):(/(?!/)" //
+ + "(file):([\\\\/](?![\\\\/])" //
+ PATH_P //
+ ")$");
@@ -159,7 +159,7 @@ public class URIish implements Serializable {
+ OPT_USER_PWD_P //
+ HOST_P //
+ ":(" //
- + ("(?:" + USER_HOME_P + "/)?") //
+ + ("(?:" + USER_HOME_P + "[\\\\/])?") //
+ RELATIVE_PATH_P //
+ ")$");
@@ -168,9 +168,9 @@ public class URIish implements Serializable {
*/
private static final Pattern ABSOLUTE_SCP_URI = Pattern.compile("^" //
+ OPT_USER_PWD_P //
- + "([^/:]{2,})" //
+ + "([^\\\\/:]{2,})" //
+ ":(" //
- + "/" + RELATIVE_PATH_P //
+ + "[\\\\/]" + RELATIVE_PATH_P //
+ ")$");
private String scheme;
@@ -192,7 +192,6 @@ public class URIish implements Serializable {
* @throws URISyntaxException
*/
public URIish(String s) throws URISyntaxException {
- s = s.replace('\\', '/');
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(s);
if (matcher.matches()) {
scheme = matcher.group(1);