mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 12:02:20 +00:00
[JENKINS-73687] Make deserialization of Map fields in XML files more robust (#9653)
* Improve resilience against malformed XML files during deserialization * Improve error message
This commit is contained in:
1 parent
d5271c8d2f
commit
dab6597416
2 files changed
+52
No files matched your search
@@ -25,6 +25,7 @@
|
||||
package hudson.util;
|
||||
|
||||
import com.thoughtworks.xstream.XStreamException;
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.collections.MapConverter;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
@@ -64,6 +65,12 @@ final class RobustMapConverter extends MapConverter {
|
||||
}
|
||||
|
||||
private Object read(HierarchicalStreamReader reader, UnmarshallingContext context, Map map) {
|
||||
if (!reader.hasMoreChildren()) {
|
||||
var exception = new ConversionException("Invalid map entry");
|
||||
reader.appendErrors(exception);
|
||||
RobustReflectionConverter.addErrorInContext(context, exception);
|
||||
return ERROR;
|
||||
}
|
||||
reader.moveDown();
|
||||
try {
|
||||
return readBareItem(reader, context, map);
|
||||
|
||||
Reference in new issue
Block a user