diff --git a/skel_common/backup/auto_update.json b/skel_common/backup/auto_update.json index 7b1b4e0..7ba5722 100644 --- a/skel_common/backup/auto_update.json +++ b/skel_common/backup/auto_update.json @@ -19,6 +19,7 @@ "Made the comments in boilerplace mod metadata optional", "Fixed omitted Validate warnings for PNG files", "Added Validate warnings about FTL 1.6.1+ for TTF, MP3, and PNG files", + "Disabled XML escaping when reencoding to ensure invalid chars cause an error", "Changed logging framework to SLF4J/Logback", "Changed command line parser to picocli" ] diff --git a/skel_common/readme_changelog.txt b/skel_common/readme_changelog.txt index 678d30d..2fa22bf 100644 --- a/skel_common/readme_changelog.txt +++ b/skel_common/readme_changelog.txt @@ -4,6 +4,7 @@ Changelog - Edited a comment in boilerplate mod metadata to include AE ships - Made the comments in boilerplace mod metadata optional - Fixed omitted Validate warnings for PNG files +- Disabled XML escaping when reencoding to ensure invalid chars cause an error - Added Validate warnings about FTL 1.6.1+ for TTF, MP3, and PNG files - Changed logging framework to SLF4J/Logback - Changed command line parser to picocli diff --git a/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java b/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java index 1818037..118f940 100644 --- a/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java +++ b/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java @@ -9,6 +9,7 @@ import org.jdom2.Content; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.Namespace; +import org.jdom2.output.EscapeStrategy; import org.jdom2.output.Format; import org.jdom2.output.LineSeparator; import org.jdom2.output.XMLOutputter; @@ -153,6 +154,9 @@ public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor { * is encoding bytes to match. If encoding is null, the default * is "UTF-8". * + * There will be no XML character entity escaping, which would have allowed + * otherwise unmappable characters to print without errors. + * * LineEndings will be CR-LF. Except for comments!? */ public static void sloppyPrint( Document doc, Writer writer, String encoding ) throws IOException { @@ -163,7 +167,16 @@ public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor { format.setIndent( "\t" ); format.setLineSeparator( LineSeparator.CRNL ); - if ( encoding != null ) format.setEncoding( encoding ); + if ( encoding != null ) { + format.setEncoding( encoding ); + } + + format.setEscapeStrategy(new EscapeStrategy() { + @Override + public boolean shouldEscape( char ch ) { + return false; + } + }); XMLOutputter outputter = new XMLOutputter( format, new SloppyXMLOutputProcessor() ); outputter.output( doc, writer );