Rename configFile to resolveFile
This method only resolves the path extracted from HttpServletRequest
relative to the site_path. It had nothing to do with ensuring that the
resolved File actually represents a config file.
Change-Id: I62e046e79c33dc15e47e723659161e7a1cebec83
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
index fd254cf..7e0e937 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serverconfig/ServerConfigServlet.java
@@ -108,7 +108,7 @@
private void writeFileAndFireAuditEvent(HttpServletRequest req,
HttpServletResponse res) throws IOException {
- File oldFile = configFile(req);
+ File oldFile = resolveFile(req);
File dir = oldFile.getParentFile();
File newFile = File.createTempFile(oldFile.getName(), ".new", dir);
streamRequestToFile(req, newFile);
@@ -173,19 +173,19 @@
}
private boolean isGerritConfig(HttpServletRequest req) throws IOException {
- File f = configFile(req);
+ File f = resolveFile(req);
return gerrit_config_path.equals(f.getCanonicalPath());
}
private boolean isValidFile(HttpServletRequest req) throws IOException {
- File f = configFile(req);
+ File f = resolveFile(req);
if (!f.isFile()) {
return false;
}
return isParent(etc_dir, f) || isParent(static_dir, f);
}
- private File configFile(HttpServletRequest req) {
+ private File resolveFile(HttpServletRequest req) {
return new File(site_path, req.getServletPath() + req.getPathInfo());
}
@@ -205,7 +205,7 @@
private void streamFile(HttpServletRequest req, HttpServletResponse res)
throws IOException {
- File f = configFile(req);
+ File f = resolveFile(req);
res.setStatus(HttpServletResponse.SC_OK);
res.setContentType("application/octet-stream");
res.setContentLength((int) f.length());
@@ -218,7 +218,7 @@
private void writeFile(HttpServletRequest req, HttpServletResponse res)
throws IOException {
res.setStatus(HttpServletResponse.SC_NO_CONTENT);
- streamRequestToFile(req, configFile(req));
+ streamRequestToFile(req, resolveFile(req));
}
private void streamRequestToFile(HttpServletRequest req, File file)