Class XmlInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.owasp.dependencycheck.xml.XmlInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Cleans up often very bad XML. Primarily, this will convert named HTM entities
into their HTM encoded Unicode code point representation.
- Strips leading white space
- Recodes £ etc to &#...;
- Recodes lone & as &
This is a slightly modified (class/method rename) from an SO answer: https://stackoverflow.com/questions/7286428/help-the-java-sax-parser-to-understand-bad-xml
- Author:
- https://stackoverflow.com/users/823393/oldcurmudgeon
-
Field Summary
Fields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintlength()NB: This is a Troll length (i.e. it goes 1, 2, many) so 2 actually means "at least 2"intread()Reads the next byte.intread(@NonNull byte[] data, int offset, int length) Reads the next length of bytes from the stream into the given byte array at the given offset.toString()To string implementation.Methods inherited from class FilterInputStream
available, close, mark, markSupported, read, reset, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
Constructor Details
-
XmlInputStream
Constructs a new XML Input Stream.- Parameters:
in- the base input stream
-
-
Method Details
-
length
public int length()NB: This is a Troll length (i.e. it goes 1, 2, many) so 2 actually means "at least 2"- Returns:
- the length
-
read
Reads the next byte.- Overrides:
readin classFilterInputStream- Returns:
- the byte read
- Throws:
IOException- thrown when there is an problem reading
-
read
Reads the next length of bytes from the stream into the given byte array at the given offset.- Overrides:
readin classFilterInputStream- Parameters:
data- the buffer to store the data readoffset- the offset in the buffer to start writinglength- the length of data to read- Returns:
- the number of bytes read
- Throws:
IOException- thrown when there is an issue with the underlying stream
-
toString
-