From f735c0427f44fbaf8c8f5d0d1fa15c4344140248 Mon Sep 17 00:00:00 2001 From: lachan-roberts Date: Mon, 6 Aug 2018 17:30:47 +1000 Subject: [PATCH] Issue #2739 - AuthenticationProtocolHandler Multiple Challenge Pattern process the param value with QuotedCSV.unquote() Signed-off-by: lachan-roberts --- .../eclipse/jetty/client/AuthenticationProtocolHandler.java | 4 ++-- .../eclipse/jetty/client/HttpClientAuthenticationTest.java | 2 +- 2 files changed, 3 insertions(+), 3 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 d3ea6f747be..7b73e931de2 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 @@ -49,7 +49,7 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler private final int maxContentLength; private final ResponseNotifier notifier; - private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:\"(?.*)\"|(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+))|(?[a-zA-Z0-9\\-._~+\\/]+=*))"); + private static final Pattern CHALLENGE_PATTERN = Pattern.compile("(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)|(?:(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s+)?(?:(?[a-zA-Z0-9\\-._~+\\/]+=*)|(?[!#$%&'*+\\-.^_`|~0-9A-Za-z]+)\\s*=\\s*(?:(?.*)))"); protected AuthenticationProtocolHandler(HttpClient client, int maxContentLength) { @@ -120,7 +120,7 @@ public abstract class AuthenticationProtocolHandler implements ProtocolHandler if (m.group("paramName") != null) { - String paramVal = (m.group("paramValueQuoted") != null) ? m.group("paramValueQuoted") : m.group("paramValueUnquoted"); + String paramVal = QuotedCSV.unquote(m.group("paramValue")); authParams.put(m.group("paramName"), paramVal); } else if (m.group("token68") != null) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAuthenticationTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAuthenticationTest.java index 5dec9c97df1..095c858e681 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAuthenticationTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientAuthenticationTest.java @@ -675,7 +675,7 @@ public class HttpClientAuthenticationTest extends AbstractHttpClientServerTest Assert.assertTrue(headerInfos.get(0).getType().equalsIgnoreCase("Newauth")); Assert.assertTrue(headerInfos.get(0).getParameter("realm").equals("apps")); Assert.assertTrue(headerInfos.get(0).getParameter("type").equals("1")); - Assert.assertThat(headerInfos.get(0).getParameter("title"), Matchers.equalTo("Login to \\\"apps\\\"")); + Assert.assertThat(headerInfos.get(0).getParameter("title"), Matchers.equalTo("Login to \"apps\"")); Assert.assertTrue(headerInfos.get(1).getType().equalsIgnoreCase("Basic")); Assert.assertTrue(headerInfos.get(1).getParameter("realm").equals("simple")); }