From 5893d8f8f89b2f6fde65c1b4b3eccfe7c4c38741 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Fri, 26 Jul 2013 12:54:09 -0400 Subject: [PATCH] fixed up parsing regular expression --- .../discovery/util/WebfingerURLNormalizer.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/openid-connect-common/src/main/java/org/mitre/discovery/util/WebfingerURLNormalizer.java b/openid-connect-common/src/main/java/org/mitre/discovery/util/WebfingerURLNormalizer.java index 1fe1eae8f..ea745eaa1 100644 --- a/openid-connect-common/src/main/java/org/mitre/discovery/util/WebfingerURLNormalizer.java +++ b/openid-connect-common/src/main/java/org/mitre/discovery/util/WebfingerURLNormalizer.java @@ -36,7 +36,19 @@ public class WebfingerURLNormalizer { private static Logger logger = LoggerFactory.getLogger(WebfingerURLNormalizer.class); // pattern used to parse user input; we can't use the built-in java URI parser - private static final Pattern pattern = Pattern.compile("^((https|acct|http|mailto):(//)?)?((([^@]+)@)?(([^:]+)(:(\\d*))?))([^\\?]+)?(\\?([^#]+))?(#(.*))?$"); + private static final Pattern pattern = Pattern.compile("^" + + "((https|acct|http|mailto|tel|device):(//)?)?" + // scheme + "(" + + "(([^@]+)@)?" + // userinfo + "(([^\\?#:/]+)" + // host + "(:(\\d*))?)" + // port + ")" + + "([^\\?#]+)?" + // path + "(\\?([^#]+))?" + // query + "(#(.*))?" + // fragment + "$" + ); + /** @@ -63,7 +75,6 @@ public class WebfingerURLNormalizer { //UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(identifier); UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); - //Pattern regex = Pattern.compile("^(([^:/?#]+):)?(//(([^@/]*)@)?([^/?#:]*)(:(\\d*))?)?([^?#]*)(\\?([^#]*))?(#(.*))?"); Matcher m = pattern.matcher(identifier); if (m.matches()) { builder.scheme(m.group(2));