Skip to content

Commit c8a1b02

Browse files
authored
Trim master password when someone uses strange XML formatting (#82)
Fixes #80
1 parent 8c04321 commit c8a1b02

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/java/org/codehaus/plexus/components/secdispatcher/internal/dispatchers/LegacyDispatcher.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,13 @@ private String getMasterMasterPasswordFromSettingsSecurityXml() {
152152
}
153153
if (Files.exists(xml)) {
154154
try (InputStream is = Files.newInputStream(xml)) {
155-
return (String) XPathFactory.newInstance()
155+
String result = (String) XPathFactory.newInstance()
156156
.newXPath()
157157
.evaluate("//master", new InputSource(is), XPathConstants.STRING);
158+
if (result != null) {
159+
result = result.trim();
160+
}
161+
return result;
158162
} catch (Exception e) {
159163
// just ignore whatever it is
160164
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<settingsSecurity>
22
<relocation>to the moon</relocation>
3-
<master>{KDvsYOFLlXgH4LU8tvpzAGg5otiosZXvfdQq0yO86LU=}</master>
3+
<master>
4+
{KDvsYOFLlXgH4LU8tvpzAGg5otiosZXvfdQq0yO86LU=}
5+
</master>
46
</settingsSecurity>

0 commit comments

Comments
 (0)