SWF-706 - ResourceServlet allows HTTP access to sensitive files

This commit is contained in:
Jeremy Grelle
2008-06-05 21:43:24 +00:00
parent 31d1425347
commit b7e5df3438
2 changed files with 10 additions and 19 deletions

View File

@@ -35,7 +35,9 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.ClassUtils;
import org.springframework.util.PathMatcher;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HttpServletBean;
@@ -248,12 +250,14 @@ public class ResourceServlet extends HttpServletBean {
if (resourcePath.matches(protectedPath)) {
return false;
}
/*
* PathMatcher pathMatcher = new AntPathMatcher(); for (int i = 0; i < allowedResourcePaths.length; i++) {
* String pattern = allowedResourcePaths[i]; if (pathMatcher.match(pattern, resourcePath)) { return true; } }
* return false;
*/
return true;
PathMatcher pathMatcher = new AntPathMatcher();
for (int i = 0; i < allowedResourcePaths.length; i++) {
String pattern = allowedResourcePaths[i];
if (pathMatcher.match(pattern, resourcePath)) {
return true;
}
}
return false;
}
/**

View File

@@ -75,19 +75,6 @@ public class ResourceServletTests extends TestCase {
assertEquals(404, response.getStatus());
}
public final void testBenchmark() throws Exception {
String requestPath = "/dojo/dojo.js";
// for (int i = 0; i < 100; i++) {
// request = new MockHttpServletRequest();
// response = new MockHttpServletResponse();
request.setPathInfo(requestPath);
servlet.doGet(request, response);
assertEquals(200, response.getStatus());
// }
}
private class ResourceTestMockServletContext extends MockServletContext {
public String getMimeType(String filePath) {