Skip to content

Commit

Permalink
Refine UriComponentsBuilder parsing
Browse files Browse the repository at this point in the history
This commit refines the expressions for the scheme, user info, host and
port parts of the URL in UriComponentsBuilder to better conform to
RFC 3986.

Fixes gh-32616
  • Loading branch information
bclozel committed Apr 11, 2024
1 parent 39cd316 commit 494ed4e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {

private static final Pattern QUERY_PARAM_PATTERN = Pattern.compile("([^&=]+)(=?)([^&]+)?");

private static final String SCHEME_PATTERN = "([^:/?#]+):";
private static final String SCHEME_PATTERN = "([^:/?#\\\\]+):";

private static final String HTTP_PATTERN = "(?i)(http|https):";

private static final String USERINFO_PATTERN = "([^/?#]*)";
private static final String USERINFO_PATTERN = "([^/?#\\\\]*)";

private static final String HOST_IPV4_PATTERN = "[^/?#:]*";
private static final String HOST_IPV4_PATTERN = "[^/?#:\\\\]*";

private static final String HOST_IPV6_PATTERN = "\\[[\\p{XDigit}:.]*[%\\p{Alnum}]*]";

private static final String HOST_PATTERN = "(" + HOST_IPV6_PATTERN + "|" + HOST_IPV4_PATTERN + ")";

private static final String PORT_PATTERN = "(\\{[^}]+\\}?|[^/?#]*)";
private static final String PORT_PATTERN = "(\\{[^}]+\\}?|[^/?#\\\\]*)";

private static final String PATH_PATTERN = "([^?#]*)";

Expand Down

0 comments on commit 494ed4e

Please sign in to comment.