From 497b87eb2ef0b21bdbb0414d22281b122117b8f6 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 17 Apr 2018 17:34:16 +1000 Subject: [PATCH] Fixed bug with regex and style cleanup. Signed-off-by: Lachlan Roberts --- .../jetty/client/AuthenticationProtocolHandler.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java index 6d3a245dce6..396cb488679 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AuthenticationProtocolHandler.java @@ -42,7 +42,7 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler { public static final int DEFAULT_MAX_CONTENT_LENGTH = 16*1024; public static final Logger LOG = Log.getLogger(AuthenticationProtocolHandler.class); - private static final Pattern AUTHENTICATE_PATTERN = Pattern.compile("([^\\s]+)\\s(.*,\\s*)?realm=\"([^\"]*)\"\\s*,?\\s*(.*)", Pattern.CASE_INSENSITIVE); + private static final Pattern AUTHENTICATE_PATTERN = Pattern.compile("([^\\s]+)\\s+(.*,\\s*)?realm=\"([^\"]*)\"\\s*,?\\s*(.*)", Pattern.CASE_INSENSITIVE); private final HttpClient client; private final int maxContentLength; @@ -242,12 +242,15 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler { String type = matcher.group(1); String realm = matcher.group(3); + String beforeRealm = matcher.group(2); + String afterRealm = matcher.group(4); + String params; - if(matcher.group(2) != null) - params = matcher.group(2) + matcher.group(4); + if (beforeRealm != null) + params = beforeRealm + afterRealm; else - params = matcher.group(4); - + params = afterRealm; + Authentication.HeaderInfo headerInfo = new Authentication.HeaderInfo(type, realm, params, getAuthorizationHeader()); result.add(headerInfo); }