Skip to content

Commit 9e862f1

Browse files
authored
Merge pull request #18 from rkoretskiy-cloudlinux/fix/quote-credentials-in-replaceFirst
Fix IllegalArgumentException when credentials contain $ or \
2 parents fc3877a + 3ed33fe commit 9e862f1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mavengem-wagon/src/main/java/org/torquebox/mojo/mavengem/wagon/MavenGemWagon.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.net.SocketAddress;
2525
import java.net.URL;
2626
import java.net.URLConnection;
27+
import java.util.regex.Matcher;
2728

2829
public class MavenGemWagon extends StreamWagon {
2930

@@ -115,7 +116,7 @@ private URL withAuthentication(String url)
115116
throws MalformedURLException {
116117
if (authenticationInfo != null && authenticationInfo.getUserName() != null) {
117118
String credentials = authenticationInfo.getUserName() + ":" + authenticationInfo.getPassword();
118-
url = url.replaceFirst("^(https?://)(.*)$", "$1" + credentials + "@$2");
119+
url = url.replaceFirst("^(https?://)(.*)$", "$1" + Matcher.quoteReplacement(credentials) + "@$2");
119120
}
120121
return new URL(url);
121122
}

0 commit comments

Comments
 (0)