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

This commit is contained in:
Nick Couchman
2018-03-25 15:02:16 -04:00
parent 16130b32fe
commit 43919e5623

View File

@@ -49,7 +49,7 @@ public class QCParser {
/**
* 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.
@@ -107,8 +107,10 @@ public class QCParser {
if (userInfo != null && !userInfo.equals("")) {
Matcher userinfoMatcher = userinfoPattern.matcher(userInfo);
username = userinfoMatcher.group(USERNAME_GROUP);
password = userinfoMatcher.group(PASSWORD_GROUP);
if (userinfoMatcher.matches()) {
username = userinfoMatcher.group(USERNAME_GROUP);
password = userinfoMatcher.group(PASSWORD_GROUP);
}
}