Skip to content

Commit 06aaedf

Browse files
committed
Make parsing stricter
1 parent c02fedd commit 06aaedf

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/main/java/org/codehaus/plexus/components/secdispatcher/internal/DefaultSecDispatcher.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,34 +128,21 @@ private Map<String, String> stripAttributes(String str) {
128128
if (start != -1 && stop != -1 && stop > start) {
129129
if (start != 0) throw new SecDispatcherException("Attributes can be prefix only");
130130
if (stop == start + 1) return null;
131-
132131
String attrs = str.substring(start + 1, stop).trim();
133-
134132
if (attrs.isEmpty()) return null;
135-
136133
Map<String, String> res = null;
137-
138134
StringTokenizer st = new StringTokenizer(attrs, ",");
139-
140135
while (st.hasMoreTokens()) {
141136
if (res == null) res = new HashMap<>(st.countTokens());
142-
143137
String pair = st.nextToken();
144-
145138
int pos = pair.indexOf('=');
146-
147-
if (pos == -1) continue;
148-
139+
if (pos == -1) throw new SecDispatcherException("Attribute malformed: " + pair);
149140
String key = pair.substring(0, pos).trim();
150-
151-
String val = pair.substring(pos + 1);
152-
153-
res.put(key, val.trim());
141+
String val = pair.substring(pos + 1).trim();
142+
res.put(key, val);
154143
}
155-
156144
return res;
157145
}
158-
159146
return null;
160147
}
161148

0 commit comments

Comments
 (0)