Skip to content

Commit

Permalink
Issue #5129 - Normalize resolved paths in PathResource
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Aug 7, 2020
1 parent 675c3cf commit 0c6530c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -240,7 +240,9 @@ public PathResource(Path path)
if (LOG.isDebugEnabled())
LOG.debug("Unable to get absolute path for {}", path, ioError);
}
this.path = absPath;

// cleanup any lingering relative path nonsense (like "/./" and "/../")
this.path = absPath.normalize();

assertValidPath(path);
this.uri = this.path.toUri();
Expand Down
Expand Up @@ -52,6 +52,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down Expand Up @@ -256,7 +257,7 @@ public void testNullPath() throws Exception
try
{
String response = connector.getResponse("GET http://localhost:8080 HTTP/1.1\r\nHost: localhost:8080\r\nConnection: close\r\n\r\n");
assertTrue(response.indexOf("200 OK") >= 0);
assertThat("Response OK", response, containsString("200 OK"));
}
finally
{
Expand Down

0 comments on commit 0c6530c

Please sign in to comment.