mirror of https://github.com/apache/jclouds.git
fix where username and password cannot both contain @
This commit is contained in:
parent
300963078c
commit
b59faeb385
|
@ -202,8 +202,8 @@ public class HttpUtils {
|
||||||
if (uriPath.indexOf('@') != 1) {
|
if (uriPath.indexOf('@') != 1) {
|
||||||
List<String> parts = Lists.newArrayList(Splitter.on('@').split(uriPath));
|
List<String> parts = Lists.newArrayList(Splitter.on('@').split(uriPath));
|
||||||
String path = parts.remove(parts.size() - 1);
|
String path = parts.remove(parts.size() - 1);
|
||||||
if (parts.size() == 2) {
|
if (parts.size() > 1) {
|
||||||
parts = Lists.newArrayList(urlEncode(parts.get(0) + "@" + parts.get(1), '/', ':'));
|
parts = Lists.newArrayList(urlEncode(Joiner.on('@').join(parts), '/', ':'));
|
||||||
}
|
}
|
||||||
parts.add(urlEncode(path, '/', ':'));
|
parts.add(urlEncode(path, '/', ':'));
|
||||||
uriPath = Joiner.on('@').join(parts);
|
uriPath = Joiner.on('@').join(parts);
|
||||||
|
|
|
@ -71,6 +71,12 @@ public class HttpUtilsTest extends PerformanceTest {
|
||||||
assertEquals(creds, URI.create("compute://user%40domain:password@terremark"));
|
assertEquals(creds, URI.create("compute://user%40domain:password@terremark"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testTerremark2() {
|
||||||
|
URI creds = HttpUtils.createUri("compute://user@domain:passw@rd@terremark");
|
||||||
|
assertEquals(creds.getUserInfo(), "user@domain:passw@rd");
|
||||||
|
assertEquals(creds, URI.create("compute://user%40domain:passw%40rd@terremark"));
|
||||||
|
}
|
||||||
|
|
||||||
public void testCloudFiles() {
|
public void testCloudFiles() {
|
||||||
URI creds = HttpUtils.createUri("compute://account:h3c@cloudfiles/container-hyphen/prefix");
|
URI creds = HttpUtils.createUri("compute://account:h3c@cloudfiles/container-hyphen/prefix");
|
||||||
assertEquals(creds, URI.create("compute://account:h3c@cloudfiles/container-hyphen/prefix"));
|
assertEquals(creds, URI.create("compute://account:h3c@cloudfiles/container-hyphen/prefix"));
|
||||||
|
|
Loading…
Reference in New Issue