@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1818
1919CDDL HEADER END
2020
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.
2222Portions Copyright 2011 Jens Elkner.
2323Portions Copyright (c) 2018-2020, Chris Fraire <[email protected] >. 2424--%>
@@ -47,6 +47,7 @@ org.opengrok.indexer.web.Util"
4747%>
4848<%@ page import =" jakarta.servlet.http.HttpServletResponse" %>
4949<%@ page import =" org.opengrok.indexer.web.SortOrder" %>
50+ <%@ page import =" java.util.Optional" %>
5051<% /* ---------------------- history.jsp start --------------------- */
5152{
5253 final Logger LOGGER = LoggerFactory . getLogger(getClass());
@@ -59,7 +60,7 @@ org.opengrok.indexer.web.Util"
5960
6061 String path = cfg. getPath();
6162
62- if (path. length() > 0 ) {
63+ if (! path. isEmpty() ) {
6364 String primePath = path;
6465 Project project = cfg. getProject();
6566 if (project != null ) {
@@ -75,8 +76,7 @@ org.opengrok.indexer.web.Util"
7576 try {
7677 primePath = searchHelper. getPrimeRelativePath(project. getName(), path);
7778 } 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);
8080 }
8181 }
8282
@@ -148,7 +148,7 @@ include file="/httpheader.jspf"
148148 request. setAttribute(" history.jsp-slider" , Util . createSlider(startIndex, max, totalHits, request));
149149% >
150150 <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()) % >
152152 (Results <span class =" bold" > <%= totalHits != 0 ? startIndex + 1 : 0 % > – <%= startIndex + thisPageIndex
153153 % > </span > of <span class =" bold" ><%= totalHits % > </span >)
154154 </div >
@@ -258,16 +258,17 @@ document.domReady.push(function() {domReadyHistory();});
258258 <%
259259 int count= 0 ;
260260 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 ;
264263 }
265- String rev = entry. getRevision();
266- if (rev == null || rev. length() == 0 ) {
267- rev = " " ;
268- }
269- String tags = hist. getTags(). get(rev);
270264
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);
271272 if (tags != null ) {
272273 int colspan;
273274 if (cfg. isDir())
@@ -285,7 +286,7 @@ document.domReady.push(function() {domReadyHistory();});
285286 <tr ><%
286287 if (cfg. isDir()) {
287288 % >
288- <td ><%= dispRev % > </td ><%
289+ <td ><%= htmlEncodedDisplayRevision % > </td ><%
289290 } else {
290291 if (entry. isActive()) {
291292 StringBuffer urlBuffer = request. getRequestURL();
@@ -297,7 +298,7 @@ document.domReady.push(function() {domReadyHistory();});
297298 <td ><a href =" <%= urlBuffer % >"
298299 title =" link to revision line" >#</a >
299300 <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 % >
301302 </a ></td >
302303 <td ><%
303304 % > <input type =" radio"
@@ -339,7 +340,7 @@ document.domReady.push(function() {domReadyHistory();});
339340 } else {
340341 striked = true ;
341342 % >
342- <td ><del ><%= dispRev % > </del ></td >
343+ <td ><del ><%= htmlEncodedDisplayRevision % > </del ></td >
343344 <td ></td ><%
344345 }
345346 }
@@ -354,23 +355,23 @@ document.domReady.push(function() {domReadyHistory();});
354355 String author = entry. getAuthor();
355356 if (author == null ) {
356357 % > (no author)<%
357- } else if (userPage != null && userPage. length() > 0 ) {
358+ } else if (userPage != null && ! userPage. isEmpty() ) {
358359 String alink = Util . getEmail(author);
359360 % > <a href =" <%= userPage + Util . htmlize(alink) + userPageSuffix
360361 % >" ><%= Util . htmlize(author) % > </a ><%
361362 } else {
362363 % ><%= Util . htmlize(author) % ><%
363364 }
364365 % > </td >
365- <td ><a id =" <%= dispRev % >" ></a ><%
366+ <td ><a id =" <%= htmlEncodedDisplayRevision % >" ></a ><%
366367 // revision message collapse threshold minimum of 10
367368 int summaryLength = Math . max(10 , cfg. getRevisionMessageCollapseThreshold());
368369 String cout = Util . htmlize(entry. getMessage());
369370
370- if (bugPage != null && bugPage. length() > 0 && bugPattern != null ) {
371+ if (bugPage != null && ! bugPage. isEmpty() && bugPattern != null ) {
371372 cout = Util . linkifyPattern(cout, bugPattern, " $1" , Util . completeUrl(bugPage + " $1" , request));
372373 }
373- if (reviewPage != null && reviewPage. length() > 0 && reviewPattern != null ) {
374+ if (reviewPage != null && ! reviewPage. isEmpty() && reviewPattern != null ) {
374375 cout = Util . linkifyPattern(cout, reviewPattern, " $1" , Util . completeUrl(reviewPage + " $1" , request));
375376 }
376377
@@ -380,10 +381,10 @@ document.domReady.push(function() {domReadyHistory();});
380381 showSummary = true ;
381382 coutSummary = coutSummary. substring(0 , summaryLength - 1 );
382383 coutSummary = Util . htmlize(coutSummary);
383- if (bugPage != null && bugPage. length() > 0 && bugPattern != null ) {
384+ if (bugPage != null && ! bugPage. isEmpty() && bugPattern != null ) {
384385 coutSummary = Util . linkifyPattern(coutSummary, bugPattern, " $1" , Util . completeUrl(bugPage + " $1" , request));
385386 }
386- if (reviewPage != null && reviewPage. length() > 0 && reviewPattern != null ) {
387+ if (reviewPage != null && ! reviewPage. isEmpty() && reviewPattern != null ) {
387388 coutSummary = Util . linkifyPattern(coutSummary, reviewPattern, " $1" , Util . completeUrl(reviewPage + " $1" , request));
388389 }
389390 }
@@ -406,11 +407,11 @@ document.domReady.push(function() {domReadyHistory();});
406407 String jfile = Util . stripPathPrefix(path, ifile);
407408 if (Objects . equals(rev, " " )) {
408409 % >
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 /><%
410411 } else {
411412 % >
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 /><%
414415 }
415416 }
416417 % > </div ><%
0 commit comments