|
@@ -17,8 +17,10 @@
|
17
|
17
|
|
18
|
18
|
package com.dmdirc.util;
|
19
|
19
|
|
|
20
|
+import java.io.UnsupportedEncodingException;
|
20
|
21
|
import java.net.URI;
|
21
|
22
|
import java.net.URISyntaxException;
|
|
23
|
+import java.net.URLDecoder;
|
22
|
24
|
import java.util.regex.Matcher;
|
23
|
25
|
import java.util.regex.Pattern;
|
24
|
26
|
|
|
@@ -83,7 +85,17 @@ public class URIParser {
|
83
|
85
|
if (!authorityMatcher.matches()) {
|
84
|
86
|
throw new InvalidURIException("Invalid address specified");
|
85
|
87
|
}
|
86
|
|
- userInfo = authorityMatcher.group("auth");
|
|
88
|
+
|
|
89
|
+ try {
|
|
90
|
+ // User info may contain special characters. When we pass individual parts to
|
|
91
|
+ // the URI constructor below, it encodes any characters not allowed in the user
|
|
92
|
+ // info. To avoid doubly-encoding them we need to decode here...
|
|
93
|
+ String auth = authorityMatcher.group("auth");
|
|
94
|
+ userInfo = auth == null ? null : URLDecoder.decode(auth, "UTF-8");
|
|
95
|
+ } catch (UnsupportedEncodingException ex) {
|
|
96
|
+ throw new InvalidURIException("Unable to create user info", ex);
|
|
97
|
+ }
|
|
98
|
+
|
87
|
99
|
host = authorityMatcher.group("host");
|
88
|
100
|
if (authorityMatcher.group("secure") != null && scheme.charAt(scheme.length() - 1) != 's') {
|
89
|
101
|
scheme += "s";
|