File tree Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Expand file tree Collapse file tree 4 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -1104,6 +1104,11 @@ public String getPath() {
1104
1104
return path ;
1105
1105
}
1106
1106
1107
+ public boolean isUnreadable () {
1108
+ File f = new File (getSourceRootPath (), getPath ());
1109
+ return f .exists () && !f .canRead ();
1110
+ }
1111
+
1107
1112
/**
1108
1113
* Get the on disk file for the given path.
1109
1114
*
Original file line number Diff line number Diff line change 268
268
<error-code >404</error-code >
269
269
<location >/enoent</location >
270
270
</error-page >
271
+ <error-page >
272
+ <error-code >403</error-code >
273
+ <location >/eforbidden</location >
274
+ </error-page >
271
275
<error-page >
272
276
<error-code >500</error-code >
273
277
<location >/error</location >
Original file line number Diff line number Diff line change @@ -16,17 +16,37 @@ information: Portions Copyright [yyyy] [name of copyright owner]
16
16
17
17
CDDL HEADER END
18
18
19
- Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
19
+ Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
20
20
Portions Copyright (c) 2018, Chris Fraire <[email protected] >.
21
21
--%>
22
- <%@page session =" false" import =" org.opengrok.web.PageConfig" %>
22
+ <%@page contentType =" text/html; charset=UTF-8" pageEncoding =" UTF-8" %>
23
+ <%@page session =" false" import =" org.opengrok.web.PageConfig" %>
24
+ <%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
23
25
<%
24
- /* ---------------------- eforbidden.jspf start --------------------- */
26
+ /* ---------------------- eforbidden.jsp start --------------------- */
25
27
{
26
28
response. setStatus(HttpServletResponse . SC_FORBIDDEN );
27
- % >
29
+ % ><% @
30
+
31
+ include file= " httpheader.jspf"
32
+
33
+ % > <body >
34
+ <div id =" page" >
35
+ <div id =" whole_header" >
36
+ <div id =" header" ><% @
37
+
38
+ include file= " pageheader.jspf"
39
+
40
+ % > </div >
41
+ </div >
42
+ <h3 class =" error" >Error: access forbidden</h3 >
43
+ <p >The request was forbidden. This can be either file/directory permissions problem or insufficient authorization.</p >
28
44
<%= PageConfig . get(request). getEnv(). getIncludeFiles(). getForbiddenIncludeFileContent(false ) % >
29
45
<%
30
46
}
31
- /* ---------------------- eforbidden.jspf end --------------------- */
47
+ /* ---------------------- eforbidden.jsp end --------------------- */
48
+ % ><% @
49
+
50
+ include file= " foot.jspf"
51
+
32
52
% >
Original file line number Diff line number Diff line change @@ -34,10 +34,16 @@ org.opengrok.web.PageConfig,
34
34
org.opengrok.indexer.web.Prefix,
35
35
org.opengrok.indexer.web.Util"%>
36
36
<%@ page import =" org.opengrok.indexer.web.messages.MessagesUtils" %>
37
+ <%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
37
38
<%
38
39
/* ---------------------- mast.jsp start --------------------- */
39
40
{
40
41
PageConfig cfg = PageConfig . get(request);
42
+ if (cfg. isUnreadable()) {
43
+ response. sendError(HttpServletResponse . SC_FORBIDDEN );
44
+ return ;
45
+ }
46
+
41
47
String redir = cfg. canProcess();
42
48
if (redir == null || redir. length() > 0 ) {
43
49
if (redir == null ) {
You can’t perform that action at this time.
0 commit comments