@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
18
18
19
19
CDDL HEADER END
20
20
21
- Copyright (c) 2005, 2022 , Oracle and/or its affiliates. All rights reserved.
21
+ Copyright (c) 2005, 2025 , Oracle and/or its affiliates. All rights reserved.
22
22
Portions Copyright 2011 Jens Elkner.
23
23
Portions Copyright (c) 2018-2020, Chris Fraire <[email protected] >.
24
24
--%>
@@ -47,6 +47,7 @@ org.opengrok.indexer.web.Util"
47
47
%>
48
48
<%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
49
49
<%@ page import =" org.opengrok.indexer.web.SortOrder" %>
50
+ <%@ page import =" java.util.Optional" %>
50
51
<% /* ---------------------- history.jsp start --------------------- */
51
52
{
52
53
final Logger LOGGER = LoggerFactory . getLogger(getClass());
@@ -59,7 +60,7 @@ org.opengrok.indexer.web.Util"
59
60
60
61
String path = cfg. getPath();
61
62
62
- if (path. length() > 0 ) {
63
+ if (! path. isEmpty() ) {
63
64
String primePath = path;
64
65
Project project = cfg. getProject();
65
66
if (project != null ) {
@@ -75,8 +76,7 @@ org.opengrok.indexer.web.Util"
75
76
try {
76
77
primePath = searchHelper. getPrimeRelativePath(project. getName(), path);
77
78
} catch (IOException | ForbiddenSymlinkException ex) {
78
- LOGGER . log(Level . WARNING , String . format(
79
- " Error getting prime relative for %s" , path), ex);
79
+ LOGGER . log(Level . WARNING , String . format(" Error getting prime relative for '%s'" , path), ex);
80
80
}
81
81
}
82
82
@@ -148,7 +148,7 @@ include file="/httpheader.jspf"
148
148
request. setAttribute(" history.jsp-slider" , Util . createSlider(startIndex, max, totalHits, request));
149
149
% >
150
150
<div id =" Masthead" >History log of
151
- <%= Util . breadcrumbPath(context + Prefix . XREF_P , path,' /' ," " ,true ,cfg. isDir()) % >
151
+ <%= Util . breadcrumbPath(context + Prefix . XREF_P , path, ' /' , " " , true , cfg. isDir()) % >
152
152
(Results <span class =" bold" > <%= totalHits != 0 ? startIndex + 1 : 0 % > – <%= startIndex + thisPageIndex
153
153
% > </span > of <span class =" bold" ><%= totalHits % > </span >)
154
154
</div >
@@ -258,16 +258,17 @@ document.domReady.push(function() {domReadyHistory();});
258
258
<%
259
259
int count= 0 ;
260
260
for (HistoryEntry entry : hist. getHistoryEntries(maxItems, startIndex)) {
261
- String dispRev = entry. getDisplayRevision();
262
- if (dispRev == null || dispRev. length() == 0 ) {
263
- dispRev = " " ;
261
+ if (Objects . isNull(entry)) {
262
+ continue ;
264
263
}
265
- String rev = entry. getRevision();
266
- if (rev == null || rev. length() == 0 ) {
267
- rev = " " ;
268
- }
269
- String tags = hist. getTags(). get(rev);
270
264
265
+ final String htmlEncodedDisplayRevision = Optional . ofNullable(entry. getDisplayRevision()).
266
+ map(Util :: htmlize).
267
+ orElse(" " );
268
+ final String rev = Optional . ofNullable(entry. getRevision()).
269
+ orElse(" " );
270
+
271
+ String tags = hist. getTags(). get(rev);
271
272
if (tags != null ) {
272
273
int colspan;
273
274
if (cfg. isDir())
@@ -285,7 +286,7 @@ document.domReady.push(function() {domReadyHistory();});
285
286
<tr ><%
286
287
if (cfg. isDir()) {
287
288
% >
288
- <td ><%= dispRev % > </td ><%
289
+ <td ><%= htmlEncodedDisplayRevision % > </td ><%
289
290
} else {
290
291
if (entry. isActive()) {
291
292
StringBuffer urlBuffer = request. getRequestURL();
@@ -297,7 +298,7 @@ document.domReady.push(function() {domReadyHistory();});
297
298
<td ><a href =" <%= urlBuffer % >"
298
299
title =" link to revision line" >#</a >
299
300
<a href =" <%= context + Prefix . XREF_P + uriEncodedName + " ?" +
300
- QueryParameters . REVISION_PARAM_EQ + Util . uriEncode(rev) % >" ><%= dispRev % >
301
+ QueryParameters . REVISION_PARAM_EQ + Util . uriEncode(rev) % >" ><%= htmlEncodedDisplayRevision % >
301
302
</a ></td >
302
303
<td ><%
303
304
% > <input type =" radio"
@@ -339,7 +340,7 @@ document.domReady.push(function() {domReadyHistory();});
339
340
} else {
340
341
striked = true ;
341
342
% >
342
- <td ><del ><%= dispRev % > </del ></td >
343
+ <td ><del ><%= htmlEncodedDisplayRevision % > </del ></td >
343
344
<td ></td ><%
344
345
}
345
346
}
@@ -354,23 +355,23 @@ document.domReady.push(function() {domReadyHistory();});
354
355
String author = entry. getAuthor();
355
356
if (author == null ) {
356
357
% > (no author)<%
357
- } else if (userPage != null && userPage. length() > 0 ) {
358
+ } else if (userPage != null && ! userPage. isEmpty() ) {
358
359
String alink = Util . getEmail(author);
359
360
% > <a href =" <%= userPage + Util . htmlize(alink) + userPageSuffix
360
361
% >" ><%= Util . htmlize(author) % > </a ><%
361
362
} else {
362
363
% ><%= Util . htmlize(author) % ><%
363
364
}
364
365
% > </td >
365
- <td ><a id =" <%= dispRev % >" ></a ><%
366
+ <td ><a id =" <%= htmlEncodedDisplayRevision % >" ></a ><%
366
367
// revision message collapse threshold minimum of 10
367
368
int summaryLength = Math . max(10 , cfg. getRevisionMessageCollapseThreshold());
368
369
String cout = Util . htmlize(entry. getMessage());
369
370
370
- if (bugPage != null && bugPage. length() > 0 && bugPattern != null ) {
371
+ if (bugPage != null && ! bugPage. isEmpty() && bugPattern != null ) {
371
372
cout = Util . linkifyPattern(cout, bugPattern, " $1" , Util . completeUrl(bugPage + " $1" , request));
372
373
}
373
- if (reviewPage != null && reviewPage. length() > 0 && reviewPattern != null ) {
374
+ if (reviewPage != null && ! reviewPage. isEmpty() && reviewPattern != null ) {
374
375
cout = Util . linkifyPattern(cout, reviewPattern, " $1" , Util . completeUrl(reviewPage + " $1" , request));
375
376
}
376
377
@@ -380,10 +381,10 @@ document.domReady.push(function() {domReadyHistory();});
380
381
showSummary = true ;
381
382
coutSummary = coutSummary. substring(0 , summaryLength - 1 );
382
383
coutSummary = Util . htmlize(coutSummary);
383
- if (bugPage != null && bugPage. length() > 0 && bugPattern != null ) {
384
+ if (bugPage != null && ! bugPage. isEmpty() && bugPattern != null ) {
384
385
coutSummary = Util . linkifyPattern(coutSummary, bugPattern, " $1" , Util . completeUrl(bugPage + " $1" , request));
385
386
}
386
- if (reviewPage != null && reviewPage. length() > 0 && reviewPattern != null ) {
387
+ if (reviewPage != null && ! reviewPage. isEmpty() && reviewPattern != null ) {
387
388
coutSummary = Util . linkifyPattern(coutSummary, reviewPattern, " $1" , Util . completeUrl(reviewPage + " $1" , request));
388
389
}
389
390
}
@@ -406,11 +407,11 @@ document.domReady.push(function() {domReadyHistory();});
406
407
String jfile = Util . stripPathPrefix(path, ifile);
407
408
if (Objects . equals(rev, " " )) {
408
409
% >
409
- <a class =" h" href =" <%= context + Prefix . XREF_P + ifile % >" ><%= jfile % > </a ><br /><%
410
+ <a class =" h" href =" <%= context + Prefix . XREF_P + Util . uriEncodePath( ifile) % >" ><%= Util . htmlize( jfile) % > </a ><br /><%
410
411
} else {
411
412
% >
412
- <a class =" h" href =" <%= context + Prefix . XREF_P + ifile % > ?<%= QueryParameters . REVISION_PARAM_EQ % >
413
- <%= rev % >" ><%= jfile % > </a ><br /><%
413
+ <a class =" h" href =" <%= context + Prefix . XREF_P + Util . uriEncodePath( ifile) % > ?<%= QueryParameters . REVISION_PARAM_EQ % >
414
+ <%= Util . uriEncode( rev) % >" ><%= Util . htmlize( jfile) % > </a ><br /><%
414
415
}
415
416
}
416
417
% > </div ><%
0 commit comments