read(getPackagePart().getInputStream());
}
- @SuppressWarnings("resource")
protected void read(InputStream is) throws IOException, XmlException {
Document doc;
try {
* The result is that they contain things like >br<, which breaks the XML parsing.
* This very sick InputStream wrapper attempts to spot these go past, and fix them.
*/
- doc = DocumentHelper.readDocument(new ReplacingInputStream(is, "<br>", "<br>"));
+ doc = DocumentHelper.readDocument(new ReplacingInputStream(is, "<br>", "<br/>"));
} catch (SAXException e) {
throw new XmlException(e.getMessage(), e);
}
@Internal
public class EvilUnclosedBRFixingInputStream extends ReplacingInputStream {
public EvilUnclosedBRFixingInputStream(InputStream source) {
- super(source, "<br>", "<br>");
+ super(source, "<br>", "<br/>");
}
}
* Excel will sometimes write a button with a textbox
* containing >br< (not closed!).
* Clearly Excel shouldn't do this, but test that we can
- * read the file despite the naughtyness
+ * read the file despite the naughtiness
*/
@Test
public void bug49020() throws IOException {
} finally {
stream.close();
}
- Pattern p = Pattern.compile("<br>");
+ Pattern p = Pattern.compile("<br/>");
int count = 0;
for (XmlObject xo : vml.getItems()) {
String split[] = p.split(xo.toString());
static class EvilUnclosedBRFixingInputStream extends ReplacingInputStream {
public EvilUnclosedBRFixingInputStream(byte[] source) {
- super(new ByteArrayInputStream(source), "<br>", "<br>");
+ super(new ByteArrayInputStream(source), "<br>", "<br/>");
}
}
@Test
public void testProblem() throws IOException {
byte[] orig = getBytes("<p><div>Hello<br>There!</div> <div>Tags!</div></p>");
- byte[] fixed = getBytes("<p><div>Hello<br>There!</div> <div>Tags!</div></p>");
+ byte[] fixed = getBytes("<p><div>Hello<br/>There!</div> <div>Tags!</div></p>");
EvilUnclosedBRFixingInputStream inp = new EvilUnclosedBRFixingInputStream(orig);
@Test
public void testBufferSize() throws IOException {
byte[] orig = getBytes("<p><div>Hello<br> <br>There!</div> <div>Tags!<br><br></div></p>");
- byte[] fixed = getBytes("<p><div>Hello<br> <br>There!</div> <div>Tags!<br><br></div></p>");
+ byte[] fixed = getBytes("<p><div>Hello<br/> <br/>There!</div> <div>Tags!<br/><br/></div></p>");
// Vary the buffer size, so that we can end up with the br in the
// overflow or only part in the buffer