import javax.servlet.http.HttpServletRequest;\r
import javax.servlet.http.HttpServletResponse;\r
\r
+import org.eclipse.jgit.lib.ObjectId;\r
import org.eclipse.jgit.lib.Ref;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revplot.AbstractPlotRenderer;\r
import org.eclipse.jgit.revplot.PlotLane;\r
import org.eclipse.jgit.revplot.PlotWalk;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.Constants;\r
import com.gitblit.IStoredSettings;\r
\r
private static final int RIGHT_PAD = 2;\r
\r
+ private final Logger log = LoggerFactory.getLogger(getClass());\r
+\r
private final Stroke[] strokeCache;\r
\r
private IStoredSettings settings;\r
@Override\r
protected long getLastModified(HttpServletRequest req) {\r
String repository = req.getParameter("r");\r
+ if (StringUtils.isEmpty(repository)) {\r
+ return 0;\r
+ }\r
String objectId = req.getParameter("h");\r
Repository r = null;\r
try {\r
if (StringUtils.isEmpty(objectId)) {\r
objectId = JGitUtils.getHEADRef(r);\r
}\r
+ ObjectId id = r.resolve(objectId);\r
+ if (id == null) {\r
+ return 0;\r
+ }\r
RevCommit commit = JGitUtils.getCommit(r, objectId);\r
return JGitUtils.getCommitDate(commit).getTime();\r
+ } catch (Exception e) {\r
+ log.error("Failed to determine last modified", e);\r
+ return 0;\r
} finally {\r
if (r != null) {\r
r.close();\r
PlotWalk rw = null;\r
try {\r
String repository = request.getParameter("r");\r
+ if (StringUtils.isEmpty(repository)) {\r
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);\r
+ response.getWriter().append("Bad request");\r
+ return;\r
+ }\r
String objectId = request.getParameter("h");\r
String length = request.getParameter("l");\r
\r
r = repositoryManager.getRepository(repository);\r
+ if (r == null) {\r
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);\r
+ response.getWriter().append("Bad request");\r
+ return;\r
+ }\r
\r
rw = new PlotWalk(r);\r
if (StringUtils.isEmpty(objectId)) {\r
objectId = JGitUtils.getHEADRef(r);\r
}\r
\r
- rw.markStart(rw.lookupCommit(r.resolve(objectId)));\r
+ ObjectId id = r.resolve(objectId);\r
+ if (id == null) {\r
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);\r
+ response.getWriter().append("Bad request");\r
+ return;\r
+ }\r
+ rw.markStart(rw.lookupCommit(id));\r
\r
// default to the items-per-page setting, unless specified\r
int maxCommits = settings.getInteger(Keys.web.itemsPerPage, 50);\r
\r
String servletUrl = request.getContextPath() + request.getServletPath();\r
String url = request.getRequestURI().substring(servletUrl.length());\r
- if (url.charAt(0) == '/' && url.length() > 1) {\r
+ if (url.length() > 1 && url.charAt(0) == '/') {\r
url = url.substring(1);\r
}\r
String repositoryName = url;\r
response.setContentType("application/rss+xml; charset=UTF-8");\r
\r
boolean isProjectFeed = false;\r
- String feedName = null;\r
+ String feedName = "Gitblit";\r
String feedTitle = null;\r
String feedDescription = null;\r
\r
RepositoryModel model = repositoryManager.getRepositoryModel(name);\r
\r
if (repository == null) {\r
- if (model.isCollectingGarbage) {\r
+ if (model != null && model.isCollectingGarbage) {\r
logger.warn(MessageFormat.format("Temporarily excluding {0} from feed, busy collecting garbage", name));\r
}\r
continue;\r