Skip to content

Commit

Permalink
Trim master password when someone uses strange XML formatting (#82)
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
cstamas authored Dec 9, 2024
1 parent 8c04321 commit c8a1b02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,13 @@ private String getMasterMasterPasswordFromSettingsSecurityXml() {
}
if (Files.exists(xml)) {
try (InputStream is = Files.newInputStream(xml)) {
return (String) XPathFactory.newInstance()
String result = (String) XPathFactory.newInstance()
.newXPath()
.evaluate("//master", new InputSource(is), XPathConstants.STRING);
if (result != null) {
result = result.trim();
}
return result;
} catch (Exception e) {
// just ignore whatever it is
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/legacy/legacy-settings-security-2.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<settingsSecurity>
<relocation>to the moon</relocation>
<master>{KDvsYOFLlXgH4LU8tvpzAGg5otiosZXvfdQq0yO86LU=}</master>
<master>
{KDvsYOFLlXgH4LU8tvpzAGg5otiosZXvfdQq0yO86LU=}
</master>
</settingsSecurity>

0 comments on commit c8a1b02

Please sign in to comment.