Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ public PrettyPrintXMLWriter(Writer writer) {
* @param doctype can be null
*/
public PrettyPrintXMLWriter(PrintWriter writer, String lineIndent, String encoding, String doctype) {
this(writer, lineIndent.toCharArray(), "\n".toCharArray(), encoding, doctype);
this(
writer,
lineIndent != null ? lineIndent.toCharArray() : DEFAULT_LINE_INDENT,
"\n".toCharArray(),
encoding,
doctype);
}

/**
Expand Down Expand Up @@ -135,7 +140,12 @@ public PrettyPrintXMLWriter(Writer writer, String encoding, String doctype) {
*/
public PrettyPrintXMLWriter(
PrintWriter writer, String lineIndent, String lineSeparator, String encoding, String doctype) {
this(writer, lineIndent.toCharArray(), lineSeparator.toCharArray(), encoding, doctype);
this(
writer,
lineIndent != null ? lineIndent.toCharArray() : DEFAULT_LINE_INDENT,
lineSeparator != null ? lineSeparator.toCharArray() : "\n".toCharArray(),
encoding,
doctype);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ public void testPrettyPrintXMLWriterWithGivenLineIndenter() throws IOException {
assertEquals(expectedResult(" "), w.toString());
}

@Test
public void testPrettyPrintXMLWriterWithNullLineIndent() throws IOException {
StringWriter sw = new StringWriter();
PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter(sw, (String) null);

writer.startElement(HTML.Tag.HTML.toString());
writeXhtmlHead(writer);
writeXhtmlBody(writer);
writer.endElement(); // Tag.HTML

assertEquals(expectedResult(), sw.toString());
}
Comment thread
Copilot marked this conversation as resolved.

@Test
public void testEscapeXmlAttributeWindows() throws IOException {
// Windows
Expand Down
Loading