Skip to content

Commit

Permalink
Issue checkstyle#5168: upgrades xml output to version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach committed Oct 2, 2022
1 parent b6f2551 commit 38eab31
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected void finishLocalSetup() {

@Override
public void auditStarted(AuditEvent event) {
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.println("<?xml version=\"1.1\" encoding=\"UTF-8\"?>");

final String version = XMLLogger.class.getPackage().getImplementationVersion();

Expand Down Expand Up @@ -273,9 +273,7 @@ public static String encode(String value) {
break;
default:
if (Character.isISOControl(chr)) {
// true escape characters need '&' before, but it also requires XML 1.1
// until https://github.com/checkstyle/checkstyle/issues/5168
sb.append("#x");
sb.append("&#x");
sb.append(Integer.toHexString(chr));
sb.append(';');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public void testExistingTargetFileXmlOutput(@SysErr Capturable systemErr,
assertWithMessage("Unexpected output log")
.that(systemOut.getCapturedData())
.isEqualTo(addEndOfLine(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<?xml version=\"1.1\" encoding=\"UTF-8\"?>",
"<checkstyle version=\"" + version + "\">",
"<file name=\"" + expectedPath + "\">",
"</file>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public void testEncode()
{"&#0;", "&amp;#0;"},
{"&#0", "&amp;#0"},
{"&#X0;", "&amp;#X0;"},
{"\u0001", "#x1;"},
{"\u0080", "#x80;"},
{"\u0001", "&#x1;"},
{"\u0080", "&#x80;"},
};
for (String[] encoding : encodings) {
final String encoded = XMLLogger.encode(encoding[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="6.16-SNAPSHOT">
<file name="/home/vlad/projects/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/ant/InputCheckstyleAntTaskError.java">
<error line="7" severity="error" message="Line is longer than 70 characters (found 80)." source="com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<file name="Test.java">
</file>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<file name="Test.java">
<error line="1" column="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<error line="1" column="1" severity="error" message="$0" source="module"/>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<error line="1" column="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/>
</checkstyle>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<file name="Test.java">
<error line="1" severity="error" message="$0" source="com.puppycrawl.tools.checkstyle.XMLLoggerTest"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<exception>
<![CDATA[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<file name="Test.java">
<exception>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<exception>
<![CDATA[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.1" encoding="UTF-8"?>
<checkstyle version="">
<exception>
<![CDATA[
Expand Down

0 comments on commit 38eab31

Please sign in to comment.