|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -92,10 +92,14 @@ public class PathResourceResolverTests { |
|
|
|
assertThat(actual).isNull(); |
|
|
|
assertThat(actual).isNull(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-23463
|
|
|
|
@Test // gh-23463
|
|
|
|
public void ignoreInvalidEscapeSequence() throws IOException { |
|
|
|
public void ignoreInvalidEscapeSequence() throws IOException { |
|
|
|
UrlResource location = new UrlResource(getClass().getResource("./test/")); |
|
|
|
UrlResource location = new UrlResource(getClass().getResource("./test/")); |
|
|
|
Resource resource = location.createRelative("test%file.txt"); |
|
|
|
|
|
|
|
|
|
|
|
Resource resource = new UrlResource(location.getURL() + "test%file.txt"); |
|
|
|
|
|
|
|
assertThat(this.resolver.checkResource(resource, location)).isTrue(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resource = location.createRelative("test%file.txt"); |
|
|
|
assertThat(this.resolver.checkResource(resource, location)).isTrue(); |
|
|
|
assertThat(this.resolver.checkResource(resource, location)).isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -112,7 +116,7 @@ public class PathResourceResolverTests { |
|
|
|
assertThat(actual).isEqualTo("../testalternatepath/bar.css"); |
|
|
|
assertThat(actual).isEqualTo("../testalternatepath/bar.css"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-12432
|
|
|
|
@Test // SPR-12432
|
|
|
|
public void checkServletContextResource() throws Exception { |
|
|
|
public void checkServletContextResource() throws Exception { |
|
|
|
Resource classpathLocation = new ClassPathResource("test/", PathResourceResolver.class); |
|
|
|
Resource classpathLocation = new ClassPathResource("test/", PathResourceResolver.class); |
|
|
|
MockServletContext context = new MockServletContext(); |
|
|
|
MockServletContext context = new MockServletContext(); |
|
|
@ -124,7 +128,7 @@ public class PathResourceResolverTests { |
|
|
|
assertThat(this.resolver.checkResource(resource, servletContextLocation)).isTrue(); |
|
|
|
assertThat(this.resolver.checkResource(resource, servletContextLocation)).isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-12624
|
|
|
|
@Test // SPR-12624
|
|
|
|
public void checkRelativeLocation() throws Exception { |
|
|
|
public void checkRelativeLocation() throws Exception { |
|
|
|
String location= new UrlResource(getClass().getResource("./test/")).getURL().toExternalForm(); |
|
|
|
String location= new UrlResource(getClass().getResource("./test/")).getURL().toExternalForm(); |
|
|
|
location = location.replace("/test/org/springframework","/test/org/../org/springframework"); |
|
|
|
location = location.replace("/test/org/springframework","/test/org/../org/springframework"); |
|
|
@ -135,13 +139,13 @@ public class PathResourceResolverTests { |
|
|
|
assertThat(actual).isNotNull(); |
|
|
|
assertThat(actual).isNotNull(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-12747
|
|
|
|
@Test // SPR-12747
|
|
|
|
public void checkFileLocation() throws Exception { |
|
|
|
public void checkFileLocation() throws Exception { |
|
|
|
Resource resource = getResource("main.css"); |
|
|
|
Resource resource = getResource("main.css"); |
|
|
|
assertThat(this.resolver.checkResource(resource, resource)).isTrue(); |
|
|
|
assertThat(this.resolver.checkResource(resource, resource)).isTrue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // SPR-13241
|
|
|
|
@Test // SPR-13241
|
|
|
|
public void resolvePathRootResource() { |
|
|
|
public void resolvePathRootResource() { |
|
|
|
Resource webjarsLocation = new ClassPathResource("/META-INF/resources/webjars/", PathResourceResolver.class); |
|
|
|
Resource webjarsLocation = new ClassPathResource("/META-INF/resources/webjars/", PathResourceResolver.class); |
|
|
|
String path = this.resolver.resolveUrlPathInternal("", Collections.singletonList(webjarsLocation), null); |
|
|
|
String path = this.resolver.resolveUrlPathInternal("", Collections.singletonList(webjarsLocation), null); |
|
|
|