diff options
author | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-03-13 17:48:19 +0100 |
---|---|---|
committer | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-03-13 17:48:19 +0100 |
commit | 16ec6d07c58356d9b20652b5ae168ae9f0fd2eaa (patch) | |
tree | 8be4fd0c5234f12a4949f47d0e3a8f17bc227508 /src/main | |
parent | 1c4fbc07c2f1898bf24e1d0076f01faa0c824b84 (diff) | |
download | gitblit-16ec6d07c58356d9b20652b5ae168ae9f0fd2eaa.tar.gz gitblit-16ec6d07c58356d9b20652b5ae168ae9f0fd2eaa.zip |
fix: Fix StoredUserConfig handling null subsections
Te `StoredUserConfig` did not handle sections without a subsection.
When the subsection did not exist, i.e. was `null`, then the subsection
name would be set to the string "null". This is not how the config file
format works. It should create a `[SECTIONNAME]` entry instead.
This fix handles a `null` subsection correctly, by handling it as a
section without a subsection.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/gitblit/StoredUserConfig.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/StoredUserConfig.java b/src/main/java/com/gitblit/StoredUserConfig.java index eae1d3cf..63e1015c 100644 --- a/src/main/java/com/gitblit/StoredUserConfig.java +++ b/src/main/java/com/gitblit/StoredUserConfig.java @@ -73,7 +73,12 @@ public class StoredUserConfig { } private static void writeSection(PrintWriter printWriter, String key, Section section) { - printWriter.printf("[%s \"%s\"]\n", section.getName(), section.getSubSection()); + if (section.getSubSection() == null) { + printWriter.printf("[%s]\n", section.getName()); + } + else { + printWriter.printf("[%s \"%s\"]\n", section.getName(), section.getSubSection()); + } for (Entry entry : section.getEntries().values()) { writeEntry(printWriter, entry.getKey(), entry.getValue()); } @@ -90,7 +95,7 @@ public class StoredUserConfig { } private static String generateKey(String key, String subKey) { - return "k:" + key + "s:" + subKey; + return "k:" + key + "s:" + (subKey == null ? "" : subKey); } private static class Section { |