HBASE-23663 Allow dot and hyphen in Profiler's URL (#1002)

Signed-off-by: Sean Busbey <busbey@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Peter Somogyi 2020-01-09 10:31:32 +01:00 committed by GitHub
parent fbf660c96b
commit 54af279ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -38,8 +38,8 @@ public class ProfileOutputServlet extends DefaultServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ProfileOutputServlet.class);
private static final int REFRESH_PERIOD = 2;
// Alphanumeric characters, plus percent (url-encoding), equals, and ampersand
private static final Pattern ALPHA_NUMERIC = Pattern.compile("[a-zA-Z0-9\\%\\=\\&]*");
// Alphanumeric characters, plus percent (url-encoding), equals, ampersand, dot and hyphen
private static final Pattern ALPHA_NUMERIC = Pattern.compile("[a-zA-Z0-9%=&.\\-]*");
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)

View File

@ -37,7 +37,8 @@ public class TestProfileOutputServlet {
@Test
public void testSanitization() {
List<String> good = Arrays.asList("abcd", "key=value", "key1=value&key2=value2", "");
List<String> good = Arrays.asList("abcd", "key=value", "key1=value&key2=value2", "",
"host=host-1.example.com");
for (String input : good) {
assertEquals(input, ProfileOutputServlet.sanitize(input));
}