Allow relative paths within resource location path
Prior to this change, location paths used for resource handling would not allow "non-cleaned, relative paths" such as `file://home/user/static/../static/`. When checking if the resolved resource's path starts with the location path, a mismatch would happen when comparing for example: * the location `file://home/user/static/../static/` * and the resource `file://home/user/static/resource.txt` This commit cleans the location path before comparing it to the resource path. Issue: SPR-12624
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -108,4 +108,13 @@ public class PathResourceResolverTests {
|
||||
assertTrue(this.resolver.checkResource(resource, servletContextLocation));
|
||||
}
|
||||
|
||||
// SPR-12624
|
||||
@Test
|
||||
public void checkRelativeLocation() throws Exception {
|
||||
String locationUrl= new UrlResource(getClass().getResource("./test/")).getURL().toExternalForm();
|
||||
Resource location = new UrlResource(locationUrl.replace("/springframework","/../org/springframework"));
|
||||
|
||||
assertNotNull(this.resolver.resolveResource(null, "main.css", Arrays.asList(location), null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user