diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java
index 3f5be5a8dd7..14c677a3654 100644
--- a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java
+++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java
@@ -660,7 +660,7 @@ public static void encode(String s, Appendable dest) throws IOException {
char c = s.charAt(i);
if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&' || c == '\'') {
// special html characters
- dest.append("").append("" + (int) c).append(";");
+ dest.append("").append(Integer.toString(c)).append(";");
} else if (c == ' ') {
// non-breaking space
dest.append(" ");
@@ -917,24 +917,22 @@ public static void writeHAD(Writer out, String ctxE, String entry) throws IOExce
/**
* Wrapper around UTF-8 URL encoding of a string.
*
- * @param q query to be encoded. If {@code null}, an empty string will be used instead.
- * @return null if failed, otherwise the encoded string
+ * @param string to be encoded. If {@code null}, an empty string will be used instead.
+ * @return {@code null} if failed, otherwise the encoded string
* @see URLEncoder#encode(String, String)
*/
- public static String uriEncode(String q) {
- return q == null ? "" : URLEncoder.encode(q, StandardCharsets.UTF_8);
+ public static String uriEncode(String string) {
+ return string == null ? "" : URLEncoder.encode(string, StandardCharsets.UTF_8);
}
/**
- * Append to {@code dest} the UTF-8 URL-encoded representation of
- * {@code str}.
+ * Append to {@code dest} the UTF-8 URL-encoded representation of {@code str}.
* @param str a defined instance
* @param dest a defined target
* @throws IOException I/O
*/
public static void uriEncode(String str, Appendable dest) throws IOException {
- String uenc = uriEncode(str);
- dest.append(uenc);
+ dest.append(uriEncode(str));
}
/**
@@ -948,7 +946,6 @@ public static void uriEncode(String str, Appendable dest) throws IOException {
* @see #uriEncode(String)
*/
public static void appendQuery(StringBuilder buf, String key, String value) {
-
if (value != null) {
buf.append(AMP).append(key).append('=').append(uriEncode(value));
}
@@ -1647,15 +1644,13 @@ public static String linkifyPattern(String text, Pattern pattern, String url) {
/**
* Try to complete the given URL part into full URL with server name, port, scheme, ...
*
- * - for request http://localhost:8080/source/xref/xxx and part
- * /cgi-bin/user=
- * - http://localhost:8080/cgi-bin/user=
- * - for request http://localhost:8080/source/xref/xxx and part
- * cgi-bin/user=
- * - http://localhost:8080/source/xref/xxx/cgi-bin/user=
- * - for request http://localhost:8080/source/xref/xxx and part
- * http://users.com/user=
- * - http://users.com/user=
+ * - for request {@code http://localhost:8080/source/xref/xxx} and part {@code /cgi-bin/user=}
+ * - {@code http://localhost:8080/cgi-bin/user=}
+ * - for request {@code http://localhost:8080/source/xref/xxx} and part {@code cgi-bin/user=}
+ * - {@code http://localhost:8080/source/xref/xxx/cgi-bin/user=}
+ * - for request {@code http://localhost:8080/source/xref/xxx} and part
+ * {@code http://users.com/user=}
+ * - {@code http://users.com/user=}
*
*
* @param url the given URL part, may be already full URL
diff --git a/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java b/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java
index f06e7107f17..6d0c0439ed3 100644
--- a/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java
+++ b/opengrok-web/src/main/java/org/opengrok/web/PageConfig.java
@@ -66,6 +66,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.core.HttpHeaders;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.VisibleForTesting;
import org.opengrok.indexer.Info;
@@ -691,6 +692,7 @@ public EftarFileReader getEftarReader() {
*
* @return an empty string if not found, the tag otherwise.
*/
+ @NotNull
public String getDefineTagsIndex() {
if (dtag != null) {
return dtag;
diff --git a/opengrok-web/src/main/webapp/rss.jsp b/opengrok-web/src/main/webapp/rss.jsp
index 41ac6135453..e78e81c16a3 100644
--- a/opengrok-web/src/main/webapp/rss.jsp
+++ b/opengrok-web/src/main/webapp/rss.jsp
@@ -40,17 +40,16 @@ org.opengrok.web.PageConfig"
PageConfig cfg = PageConfig.get(request);
cfg.checkSourceRootExistence();
- String redir = cfg.canProcess();
- if (redir == null || !redir.isEmpty()) {
- if (redir != null) {
- response.sendRedirect(redir);
+ String redirectLocation = cfg.canProcess();
+ if (redirectLocation == null || !redirectLocation.isEmpty()) {
+ if (redirectLocation != null) {
+ response.sendRedirect(redirectLocation);
} else {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
return;
}
String path = cfg.getPath();
- String dtag = cfg.getDefineTagsIndex();
response.setContentType("text/xml");
%>
Changes in <%= path.isEmpty()
? "Cross Reference"
: Util.htmlize(cfg.getResourceFile().getName()) %>
- <%= Util.htmlize(dtag) %>
+ <%= Util.htmlize(cfg.getDefineTagsIndex()) %>
en
Copyright 2025
Java<%
- History hist;
- if(cfg.isDir()) {
- hist = new DirectoryHistoryReader(cfg.getHistoryDirs()).getHistory();
+ History history;
+ if (cfg.isDir()) {
+ history = new DirectoryHistoryReader(cfg.getHistoryDirs()).getHistory();
} else {
- hist = HistoryGuru.getInstance().getHistory(cfg.getResourceFile());
+ history = HistoryGuru.getInstance().getHistory(cfg.getResourceFile());
}
- if (hist != null) {
+ if (history != null) {
int i = 20;
- for (HistoryEntry entry : hist.getHistoryEntries()) {
+ for (HistoryEntry entry : history.getHistoryEntries()) {
if (i-- <= 0) {
break;
}
@@ -88,17 +87,17 @@ org.opengrok.web.PageConfig"
String replaced = entry.getMessage().split("\n")[0];
%><%= Util.htmlize(entry.getRevision()) %> - <%= Util.htmlize(replaced) %>
<%
- String requestURL = request.getScheme() + "://";
- String serverName = cfg.getServerName();
- requestURL += serverName;
- String port = Integer.toString(request.getLocalPort());
- if (!port.isEmpty()) {
- requestURL += ":" + port;
- }
-
- requestURL += request.getContextPath();
- requestURL += Prefix.HIST_L + cfg.getPath() + "#" + entry.getRevision();
- %><%= Util.htmlize(requestURL) %>
+ String requestURL = request.getScheme() +
+ "://" +
+ cfg.getServerName() +
+ ":" +
+ request.getLocalPort() +
+ Util.uriEncodePath(request.getContextPath()) +
+ Prefix.HIST_L +
+ Util.uriEncodePath(cfg.getPath()) +
+ "#" +
+ Util.uriEncode(entry.getRevision());
+ %><%= requestURL %>
<%
for (String e : entry.getMessage().split("\n")) {
%>
@@ -111,9 +110,9 @@ org.opengrok.web.PageConfig"
if (cfg.isDir()) {
Set files = entry.getFiles();
if (files != null) {
- for (String ifile : files) {
+ for (String entryFile : files) {
%>
- <%= Util.htmlize(ifile) %><%
+ <%= Util.htmlize(entryFile) %><%
}
}
} else {