mirror of
https://github.com/praktimarc/kst4contest.git
synced 2026-11-19 01:52:29 +01:00
Harden the setup wizard after the branch review
Written-by: Gemini 4 Hydrogen (Antigravity) Written-by: Claude Fable 5.2
This commit is contained in:
13 files changed
+248
-31
No files matched your search
@@ -2619,6 +2619,10 @@ public class ChatPreferences {
|
||||
|
||||
DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
Document doc = db.parse(xmlConfigFile);
|
||||
Element rootElement = doc.getDocumentElement();
|
||||
if (rootElement == null || !"praktiKST".equals(rootElement.getTagName())) {
|
||||
readable = false;
|
||||
}
|
||||
NodeList list;
|
||||
|
||||
// --- Schema version (optional) ---
|
||||
|
||||
@@ -45,6 +45,18 @@ class ChatPreferencesReadResultTest {
|
||||
assertFalse(Files.exists(file), "reading a missing file must not create it");
|
||||
}
|
||||
|
||||
@Test
|
||||
void aWellFormedXmlWithForeignRootIsReportedAsUnreadable() throws IOException {
|
||||
Path file = temporaryDirectory.resolve("foreign.xml");
|
||||
byte[] original = "<somethingElse><station><LoginCallSign>DL0TEST</LoginCallSign></station></somethingElse>"
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
Files.write(file, original);
|
||||
|
||||
ChatPreferences preferences = new ChatPreferences(file);
|
||||
assertFalse(preferences.readPreferencesFromXmlFile(), "a foreign XML root must be reported as unreadable");
|
||||
assertArrayEquals(original, Files.readAllBytes(file), "the foreign XML file must be left untouched");
|
||||
}
|
||||
|
||||
@Test
|
||||
void theBundledTemplateIsReadable() throws IOException {
|
||||
Path templateCopy = temporaryDirectory.resolve("template.xml");
|
||||
|
||||
Reference in new issue
Block a user