diff options
Diffstat (limited to 'gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java')
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java index b37a152f28..7de4bc3757 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/GitWebConfig.java @@ -41,9 +41,33 @@ public class GitWebConfig { final String cfgCgi = cfg.getString("gitweb", null, "cgi"); type = GitWebType.fromName(cfg.getString("gitweb", null, "type")); + if (type == null) { + url = null; + gitweb_cgi = null; + gitweb_css = null; + gitweb_js = null; + git_logo_png = null; + return; + } + + type.setLinkName(cfg.getString("gitweb", null, "linkname")); type.setBranch(cfg.getString("gitweb", null, "branch")); type.setProject(cfg.getString("gitweb", null, "project")); type.setRevision(cfg.getString("gitweb", null, "revision")); + type.setFileHistory(cfg.getString("gitweb", null, "filehistory")); + String pathSeparator = cfg.getString("gitweb", null, "pathSeparator"); + if (pathSeparator != null) { + if (pathSeparator.length() == 1) { + char c = pathSeparator.charAt(0); + if (isValidPathSeparator(c)) { + type.setPathSeparator(c); + } else { + log.warn("Invalid value specified for gitweb.pathSeparator: " + c); + } + } else { + log.warn("Value specified for gitweb.pathSeparator is not a single character:" + pathSeparator); + } + } if (type.getBranch() == null) { log.warn("No Pattern specified for gitweb.branch, disabling."); @@ -54,10 +78,13 @@ public class GitWebConfig { } else if (type.getRevision() == null) { log.warn("No Pattern specified for gitweb.revision, disabling."); type = null; + } else if (type.getFileHistory() == null) { + log.warn("No Pattern specified for gitweb.filehistory, disabling."); + type = null; } if ((cfgUrl != null && cfgUrl.isEmpty()) - || (cfgCgi != null && cfgCgi.isEmpty()) || type == null) { + || (cfgCgi != null && cfgCgi.isEmpty())) { // Either setting was explicitly set to the empty string disabling // gitweb for this server. Disable the configuration. // @@ -172,4 +199,31 @@ public class GitWebConfig { public File getGitLogoPNG() { return git_logo_png; } + + /** + * Determines if a given character can be used unencoded in an URL as a + * replacement for the path separator '/'. + * + * Reasoning: http://www.ietf.org/rfc/rfc1738.txt ยง 2.2: + * + * ... only alphanumerics, the special characters "$-_.+!*'(),", and + * reserved characters used for their reserved purposes may be used + * unencoded within a URL. + * + * The following characters might occur in file names, however: + * + * alphanumeric characters, + * + * "$-_.+!'," + */ + static boolean isValidPathSeparator(char c) { + switch (c) { + case '*': + case '(': + case ')': + return true; + default: + return false; + } + } } |