Browse Source

Bug 484342: Support @ in username in SSH url.

Change-Id: I5795e925afff796488ba26c83694e806b76a374f
Signed-off-by: Mike Gilbode <gilbode@gmail.com>
stable-4.3
Mike Gilbode 9 years ago
parent
commit
3e03907f65
  1. 42
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

42
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java

@ -468,6 +468,48 @@ public class URIishTest {
assertEquals(u, new URIish(str));
}
@Test
public void testSshProtoWithEmailUserAndPort() throws Exception {
final String str = "ssh://user.name@email.com@example.com:33/some/p ath";
URIish u = new URIish(str);
assertEquals("ssh", u.getScheme());
assertTrue(u.isRemote());
assertEquals("/some/p ath", u.getRawPath());
assertEquals("/some/p ath", u.getPath());
assertEquals("example.com", u.getHost());
assertEquals("user.name@email.com", u.getUser());
assertNull(u.getPass());
assertEquals(33, u.getPort());
assertEquals("ssh://user.name%40email.com@example.com:33/some/p ath",
u.toPrivateString());
assertEquals("ssh://user.name%40email.com@example.com:33/some/p%20ath",
u.toPrivateASCIIString());
assertEquals(u.setPass(null).toPrivateString(), u.toString());
assertEquals(u.setPass(null).toPrivateASCIIString(), u.toASCIIString());
assertEquals(u, new URIish(str));
}
@Test
public void testSshProtoWithEmailUserPassAndPort() throws Exception {
final String str = "ssh://user.name@email.com:pass@wor:d@example.com:33/some/p ath";
URIish u = new URIish(str);
assertEquals("ssh", u.getScheme());
assertTrue(u.isRemote());
assertEquals("/some/p ath", u.getRawPath());
assertEquals("/some/p ath", u.getPath());
assertEquals("example.com", u.getHost());
assertEquals("user.name@email.com", u.getUser());
assertEquals("pass@wor:d", u.getPass());
assertEquals(33, u.getPort());
assertEquals("ssh://user.name%40email.com:pass%40wor%3ad@example.com:33/some/p ath",
u.toPrivateString());
assertEquals("ssh://user.name%40email.com:pass%40wor%3ad@example.com:33/some/p%20ath",
u.toPrivateASCIIString());
assertEquals(u.setPass(null).toPrivateString(), u.toString());
assertEquals(u.setPass(null).toPrivateASCIIString(), u.toASCIIString());
assertEquals(u, new URIish(str));
}
@Test
public void testSshProtoWithADUserPassAndPort() throws Exception {
final String str = "ssh://DOMAIN\\user:pass@example.com:33/some/p ath";

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/URIish.java

@ -83,7 +83,7 @@ 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 = "(?:([^/:@]+)(?::([^\\\\/]+))?@)?"; //$NON-NLS-1$
private static final String OPT_USER_PWD_P = "(?:([^/:]+)(?::([^\\\\/]+))?@)?"; //$NON-NLS-1$
/**
* Part of a pattern which matches the host part of URIs. Defines one

Loading…
Cancel
Save