GUACAMOLE-38: Tweak to regex and correct behavior of matcher.

This commit is contained in:
Nick Couchman committed 2018-06-01 13:40:51 -04:00
1 parent 16130b32fe
commit 43919e5623
1 file changed
+5 -3
@@ -49,7 +49,7 @@ public class QCParser {
/** /**
* The regex to use to split username and password. * The regex to use to split username and password.
*/ */
private static final Pattern userinfoPattern = Pattern.compile("(^[^:]+):(.*)"); private static final Pattern userinfoPattern = Pattern.compile("(^[^:]+):?(.*)");
/** /**
* The regex group of the username. * The regex group of the username.
@@ -107,8 +107,10 @@ public class QCParser {
if (userInfo != null && !userInfo.equals("")) { if (userInfo != null && !userInfo.equals("")) {
Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); Matcher userinfoMatcher = userinfoPattern.matcher(userInfo);
username = userinfoMatcher.group(USERNAME_GROUP); if (userinfoMatcher.matches()) {
password = userinfoMatcher.group(PASSWORD_GROUP); username = userinfoMatcher.group(USERNAME_GROUP);
password = userinfoMatcher.group(PASSWORD_GROUP);
}
} }