mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-15 14:53:31 +00:00
SEC-1802: Add digits to valid URL scheme regex.
This commit is contained in:
parent
2fd0a65049
commit
f1e63f3008
@ -129,7 +129,7 @@ public final class UrlUtils {
|
|||||||
* Decides if a URL is absolute based on whether it contains a valid scheme name, as defined in RFC 1738.
|
* Decides if a URL is absolute based on whether it contains a valid scheme name, as defined in RFC 1738.
|
||||||
*/
|
*/
|
||||||
public static boolean isAbsoluteUrl(String url) {
|
public static boolean isAbsoluteUrl(String url) {
|
||||||
final Pattern ABSOLUTE_URL = Pattern.compile("\\A[a-z.+-]+://.*", Pattern.CASE_INSENSITIVE);
|
final Pattern ABSOLUTE_URL = Pattern.compile("\\A[a-z0-9.+-]+://.*", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
return ABSOLUTE_URL.matcher(url).matches();
|
return ABSOLUTE_URL.matcher(url).matches();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ public class UrlUtilsTests {
|
|||||||
@Test
|
@Test
|
||||||
public void absoluteUrlsAreMatchedAsAbsolute() throws Exception {
|
public void absoluteUrlsAreMatchedAsAbsolute() throws Exception {
|
||||||
assertTrue(UrlUtils.isAbsoluteUrl("http://something/"));
|
assertTrue(UrlUtils.isAbsoluteUrl("http://something/"));
|
||||||
|
assertTrue(UrlUtils.isAbsoluteUrl("http1://something/"));
|
||||||
assertTrue(UrlUtils.isAbsoluteUrl("HTTP://something/"));
|
assertTrue(UrlUtils.isAbsoluteUrl("HTTP://something/"));
|
||||||
assertTrue(UrlUtils.isAbsoluteUrl("https://something/"));
|
assertTrue(UrlUtils.isAbsoluteUrl("https://something/"));
|
||||||
assertTrue(UrlUtils.isAbsoluteUrl("a://something/"));
|
assertTrue(UrlUtils.isAbsoluteUrl("a://something/"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user