Skip to content

Commit 324429b

Browse files
tulinkryVladimir Kotal
authored andcommitted
displaying 404 not found for no history (#1586)
fixes #1571
1 parent be1c243 commit 324429b

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

web/history.jsp

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
2222
2323
Portions Copyright 2011 Jens Elkner.
2424
25-
--%><%@page import="org.opensolaris.opengrok.web.Util"%>
25+
--%>
26+
<%@page import="org.opensolaris.opengrok.web.Util"%>
2627
<%@page import="org.opensolaris.opengrok.history.HistoryGuru"%>
2728
<%@page import="java.io.File"%>
2829
<%@page errorPage="error.jsp" import="
@@ -45,16 +46,7 @@ org.opensolaris.opengrok.configuration.RuntimeEnvironment"
4546
4647
// Need to set the title before inlcuding httpheader.jspf
4748
cfg.setTitle(cfg.getHistoryTitle());
48-
}
49-
%>
50-
<%@
5149
52-
include file="httpheader.jspf"
53-
54-
%>
55-
<%
56-
{
57-
PageConfig cfg = PageConfig.get(request);
5850
String path = cfg.getPath();
5951
6052
if (path.length() > 0) {
@@ -64,10 +56,31 @@ include file="httpheader.jspf"
6456
hist = HistoryGuru.getInstance().getHistoryUI(f);
6557
} catch (Exception e) {
6658
// should not happen
67-
%><h3>Problem</h3><p class="error"><%= e.getMessage() %></p><%
59+
response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
60+
return;
6861
}
69-
if (hist != null) {
70-
request.setAttribute("history.jsp-hist", hist);
62+
63+
if (hist == null) {
64+
/**
65+
* The history is not available even for a renamed file.
66+
* Send 404 Not Found.
67+
*/
68+
response.sendError(HttpServletResponse.SC_NOT_FOUND);
69+
return;
70+
}
71+
request.setAttribute("history.jsp-hist", hist);
72+
}
73+
}
74+
%>
75+
<%@
76+
77+
include file="httpheader.jspf"
78+
79+
%>
80+
<%
81+
{
82+
PageConfig cfg = PageConfig.get(request);
83+
if ((request.getAttribute("history.jsp-hist")) != null) {
7184
%>
7285
<body>
7386
<script type="text/javascript">/* <![CDATA[ */
@@ -80,7 +93,6 @@ include file="httpheader.jspf"
8093
<div id="whole_header">
8194
<div id="header">
8295
<%
83-
}
8496
}
8597
}
8698
{

0 commit comments

Comments
 (0)