Skip to content

Support fragments in UriComponentsBuilder.fromHttpUrl() #25300

Closed
@ljosefik

Description

@ljosefik

Method fromHttpUrl ends with IllegalArgumentException if parameter contain fragment

java.lang.IllegalArgumentException: [https://tools.ietf.org/html/rfc6749#section-4.1] is not a valid HTTP URL

Test case:

        String redirectUri = "https://tools.ietf.org/html/rfc6749#section-4.1";
        java.net.URL url1 = new URL(redirectUri);
        UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromUriString(redirectUri);
        //UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(redirectUri);

From code (for URL '#' missing):

	// Regex patterns that matches URIs. See RFC 3986, appendix B
	private static final Pattern URI_PATTERN = Pattern.compile(
			"^(" + SCHEME_PATTERN + ")?" + "(//(" + USERINFO_PATTERN + "@)?" + HOST_PATTERN + "(:" + PORT_PATTERN +
					")?" + ")?" + PATH_PATTERN + "(\\?" + QUERY_PATTERN + ")?" + "(#" + LAST_PATTERN + ")?");

	private static final Pattern HTTP_URL_PATTERN = Pattern.compile(
			"^" + HTTP_PATTERN + "(//(" + USERINFO_PATTERN + "@)?" + HOST_PATTERN + "(:" + PORT_PATTERN + ")?" + ")?" +
					PATH_PATTERN + "(\\?" + LAST_PATTERN + ")?");

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions