From 8ed1b96f3ad00bb0a1522315781ec22f1f20add4 Mon Sep 17 00:00:00 2001 From: zzz Date: Sun, 29 Apr 2018 20:57:47 +0000 Subject: [PATCH] Console: Fix NPE on /configsidebar (ticket #2220) Don't throw NPE translating null Add note about split() Fix form inside table --- .../i2p/router/web/helpers/SummaryHelper.java | 16 ++++++++++++---- apps/routerconsole/jsp/configsidebar.jsp | 4 ++-- core/java/src/net/i2p/data/DataHelper.java | 6 ++++++ core/java/src/net/i2p/util/Translate.java | 4 ++++ history.txt | 8 ++++++++ .../java/src/net/i2p/router/RouterVersion.java | 2 +- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java index abed7326a..9334e6b15 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/SummaryHelper.java @@ -1006,6 +1006,8 @@ public class SummaryHelper extends HelperBase { if (config == null) config = _context.getProperty(PROP_SUMMARYBAR + "default", isAdvanced() ? DEFAULT_FULL_ADVANCED : DEFAULT_FULL); } + if (config.length() <= 0) + return Collections.emptyList(); return Arrays.asList(DataHelper.split(config, SS)); } @@ -1081,14 +1083,17 @@ public class SummaryHelper extends HelperBase { .append("\n"); for (String section : sections) { int i = sections.indexOf(section); + String name = sectionNames.get(section); + if (name == null) + continue; buf.append("\n"); for (String s : sortedSections) { + String name = sectionNames.get(s); + if (name == null) + continue; buf.append("\n"); + .append(name).append("\n"); } buf.append("\n" + diff --git a/apps/routerconsole/jsp/configsidebar.jsp b/apps/routerconsole/jsp/configsidebar.jsp index 98fc3c6e5..5f01cf1b7 100644 --- a/apps/routerconsole/jsp/configsidebar.jsp +++ b/apps/routerconsole/jsp/configsidebar.jsp @@ -30,9 +30,9 @@ input.default { " />

<%=intl._t("Refresh Interval")%>

+
- -
@@ -42,9 +42,9 @@ input.default { " >
+

<%=intl._t("Customize Summary Bar")%>

diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 1b1c8acd5..7c2cf9a4c 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -1950,6 +1950,9 @@ public class DataHelper { * Same as s.split(regex) but caches the compiled pattern for speed. * This saves about 10 microseconds (Bulldozer) on subsequent invocations. * + * Note: For an input "" this returns [""], not a zero-length array. + * This is the same behavior as String.split(). + * * @param s non-null * @param regex non-null, don't forget to enclose multiple choices with [] * @throws java.util.regex.PatternSyntaxException unchecked @@ -1965,6 +1968,9 @@ public class DataHelper { * Same as s.split(regex, limit) but caches the compiled pattern for speed. * This saves about 10 microseconds (Bulldozer) on subsequent invocations. * + * Note: For an input "" this returns [""], not a zero-length array. + * This is the same behavior as String.split(). + * * @param s non-null * @param regex non-null, don't forget to enclose multiple choices with [] * @param limit result threshold diff --git a/core/java/src/net/i2p/util/Translate.java b/core/java/src/net/i2p/util/Translate.java index 0c42f8056..763c3370d 100644 --- a/core/java/src/net/i2p/util/Translate.java +++ b/core/java/src/net/i2p/util/Translate.java @@ -43,6 +43,10 @@ public abstract class Translate { /** lang in routerconsole.lang property, else current locale */ public static String getString(String key, I2PAppContext ctx, String bun) { + if (key == null) { + (new NullPointerException("null translation string")).printStackTrace(); + return ""; + } String lang = getLanguage(ctx); if (lang.equals("en")) return key; diff --git a/history.txt b/history.txt index de225554b..0a3037c8f 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,11 @@ +2018-04-29 zzz + * Console: Fix NPE on /configsidebar (ticket #2220) + +2018-04-28 zzz + * i2ptunnel: + - Fix startup deadlock in TCG + - Initial work on SSL wizard + 2018-04-27 zzz * Tunnels: Fix and consolidate allow-zero-hop logic, prevent zero-hop client tunnels when no active peers diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index fecba78d6..a6204817e 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 7; + public final static long BUILD = 8; /** for example "-test" */ public final static String EXTRA = "";