Console: Fix NPE on /configsidebar (ticket #2220)

Don't throw NPE translating null
Add note about split()
Fix form inside table
This commit is contained in:
zzz
2018-04-29 20:57:47 +00:00
parent c73b5b9edb
commit 8ed1b96f3a
6 changed files with 33 additions and 7 deletions

View File

@ -1006,6 +1006,8 @@ public class SummaryHelper extends HelperBase {
if (config == null) if (config == null)
config = _context.getProperty(PROP_SUMMARYBAR + "default", isAdvanced() ? DEFAULT_FULL_ADVANCED : DEFAULT_FULL); 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)); return Arrays.asList(DataHelper.split(config, SS));
} }
@ -1081,14 +1083,17 @@ public class SummaryHelper extends HelperBase {
.append("</th></tr>\n"); .append("</th></tr>\n");
for (String section : sections) { for (String section : sections) {
int i = sections.indexOf(section); int i = sections.indexOf(section);
String name = sectionNames.get(section);
if (name == null)
continue;
buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" id=\"") buf.append("<tr><td align=\"center\"><input type=\"checkbox\" class=\"optbox\" id=\"")
.append(sectionNames.get(section)) .append(name)
.append("\" name=\"delete_") .append("\" name=\"delete_")
.append(i) .append(i)
.append("\"></td><td align=\"left\"><label for=\"") .append("\"></td><td align=\"left\"><label for=\"")
.append(sectionNames.get(section)) .append(name)
.append("\">") .append("\">")
.append(_t(sectionNames.get(section))) .append(_t(name))
.append("</label></td><td align=\"right\"><input type=\"hidden\" name=\"order_") .append("</label></td><td align=\"right\"><input type=\"hidden\" name=\"order_")
.append(i).append('_').append(section) .append(i).append('_').append(section)
.append("\" value=\"") .append("\" value=\"")
@ -1151,8 +1156,11 @@ public class SummaryHelper extends HelperBase {
.append("</option>\n"); .append("</option>\n");
for (String s : sortedSections) { for (String s : sortedSections) {
String name = sectionNames.get(s);
if (name == null)
continue;
buf.append("<option value=\"").append(s).append("\">") buf.append("<option value=\"").append(s).append("\">")
.append(sectionNames.get(s)).append("</option>\n"); .append(name).append("</option>\n");
} }
buf.append("</select>\n" + buf.append("</select>\n" +

View File

@ -30,9 +30,9 @@ input.default {
<jsp:setProperty name="summaryhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" /> <jsp:setProperty name="summaryhelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
<h3 class="tabletitle"><%=intl._t("Refresh Interval")%></h3> <h3 class="tabletitle"><%=intl._t("Refresh Interval")%></h3>
<form action="" method="POST">
<table class="configtable"> <table class="configtable">
<tr> <tr>
<form action="" method="POST">
<td> <td>
<input type="hidden" name="nonce" value="<%=pageNonce%>" > <input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="group" value="0"> <input type="hidden" name="group" value="0">
@ -42,9 +42,9 @@ input.default {
<td class="optionsave"> <td class="optionsave">
<input type="submit" name="action" class="accept" value="<%=intl._t("Save")%>" > <input type="submit" name="action" class="accept" value="<%=intl._t("Save")%>" >
</td> </td>
</form>
</tr> </tr>
</table> </table>
</form>
<h3 class="tabletitle"><%=intl._t("Customize Summary Bar")%></h3> <h3 class="tabletitle"><%=intl._t("Customize Summary Bar")%></h3>
<form action="" method="POST"> <form action="" method="POST">

View File

@ -1950,6 +1950,9 @@ public class DataHelper {
* Same as s.split(regex) but caches the compiled pattern for speed. * Same as s.split(regex) but caches the compiled pattern for speed.
* This saves about 10 microseconds (Bulldozer) on subsequent invocations. * 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 s non-null
* @param regex non-null, don't forget to enclose multiple choices with [] * @param regex non-null, don't forget to enclose multiple choices with []
* @throws java.util.regex.PatternSyntaxException unchecked * @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. * Same as s.split(regex, limit) but caches the compiled pattern for speed.
* This saves about 10 microseconds (Bulldozer) on subsequent invocations. * 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 s non-null
* @param regex non-null, don't forget to enclose multiple choices with [] * @param regex non-null, don't forget to enclose multiple choices with []
* @param limit result threshold * @param limit result threshold

View File

@ -43,6 +43,10 @@ public abstract class Translate {
/** lang in routerconsole.lang property, else current locale */ /** lang in routerconsole.lang property, else current locale */
public static String getString(String key, I2PAppContext ctx, String bun) { public static String getString(String key, I2PAppContext ctx, String bun) {
if (key == null) {
(new NullPointerException("null translation string")).printStackTrace();
return "";
}
String lang = getLanguage(ctx); String lang = getLanguage(ctx);
if (lang.equals("en")) if (lang.equals("en"))
return key; return key;

View File

@ -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 2018-04-27 zzz
* Tunnels: Fix and consolidate allow-zero-hop logic, * Tunnels: Fix and consolidate allow-zero-hop logic,
prevent zero-hop client tunnels when no active peers prevent zero-hop client tunnels when no active peers

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 7; public final static long BUILD = 8;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";