Skip to content

Conversation

billyto
Copy link
Contributor

@billyto billyto commented Jul 23, 2021

The Sanitizer.java class infers that the scheme portion of a URI can only contain letters, but as described in RFC2396 it can follow:

scheme = alpha *( alpha | digit | "+" | "-" | "." )

We have a use case where a valid URI with the scheme mongodb+sr, won't get the password token sanitized due to the current regex pattern.

@pivotal-cla
Copy link

@billyto Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@billyto Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 23, 2021
Copy link
Member

@wilkinsona wilkinsona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the pull request, @billyto. I left one comment regarding the updated regex. Could you please take a look when you have a moment?

@@ -50,7 +50,7 @@
private static final Set<String> URI_USERINFO_KEYS = new LinkedHashSet<>(
Arrays.asList("uri", "uris", "url", "urls", "address", "addresses"));

private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("\\[?[A-Za-z]+://.+:(.*)@.+$");
private static final Pattern URI_USERINFO_PATTERN = Pattern.compile("^[A-Za-z][\\w\\+\\.\\-]+://.+:(.*)@.+$");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes _ which I don't think is correct here. Should it be A-Za-z0-9 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally correct, good catch! Let me fix it in a couple of hours when getting back home.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jul 24, 2021
as \w includes underscore character "_"
@billyto billyto requested a review from wilkinsona July 24, 2021 22:39
@wilkinsona wilkinsona changed the title Change scheme match pattern for Sanitizing URIs A URI with non-alpha characters in its scheme is not sanitized Jul 26, 2021
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Jul 26, 2021
@wilkinsona wilkinsona added this to the 2.4.x milestone Jul 26, 2021
@wilkinsona
Copy link
Member

Thanks very much for making your first contribution to Spring Boot, @billyto.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants