mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Merge branch '7.0.x'
Closes gh-36753
This commit is contained in:
-3
@@ -74,9 +74,6 @@ public abstract class ResourceHandlerUtils {
|
||||
}
|
||||
else if (location instanceof ContextResource contextResource) {
|
||||
path = contextResource.getPathWithinContext();
|
||||
Assert.isTrue(!"/".equals(path),
|
||||
() -> "Resource location '" + location + "' is considered unsafe " +
|
||||
"and cannot be used as it provides access to the root servlet context.");
|
||||
}
|
||||
else if (location instanceof UrlResource) {
|
||||
path = location.getURL().toExternalForm();
|
||||
|
||||
-7
@@ -82,13 +82,6 @@ class ResourceHandlerUtilsTests {
|
||||
.withMessageContaining("is considered unsafe");
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertResourceLocationShouldRejectUnsafeContextResource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResourceHandlerUtils.assertResourceLocation(new TestContextResource("/")))
|
||||
.withMessageContaining("is considered unsafe");
|
||||
}
|
||||
|
||||
private static class TestContextResource implements ContextResource {
|
||||
|
||||
private final String path;
|
||||
|
||||
-3
@@ -75,9 +75,6 @@ public abstract class ResourceHandlerUtils {
|
||||
}
|
||||
else if (location instanceof ContextResource contextResource) {
|
||||
path = contextResource.getPathWithinContext();
|
||||
Assert.isTrue(!"/".equals(path),
|
||||
() -> "Resource location '" + location + "' is considered unsafe " +
|
||||
"and cannot be used as it provides access to the root servlet context.");
|
||||
}
|
||||
else if (location instanceof UrlResource) {
|
||||
path = location.getURL().toExternalForm();
|
||||
|
||||
-7
@@ -77,11 +77,4 @@ class ResourceHandlerUtilsTests {
|
||||
.withMessageContaining("is considered unsafe");
|
||||
}
|
||||
|
||||
@Test
|
||||
void assertResourceLocationShouldRejectUnsafeContextResource() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
ResourceHandlerUtils.assertResourceLocation(new ServletContextResource(new MockServletContext(), "/")))
|
||||
.withMessageContaining("is considered unsafe");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user