From ef276e421f0a3f33fdd7ca6e61611f184c7918e0 Mon Sep 17 00:00:00 2001 From: Vhati Date: Tue, 3 Sep 2013 16:21:57 -0400 Subject: [PATCH] Made comment tags that contain a start-comment bracket into two comments --- .../modmanager/core/SloppyXMLParser.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/vhati/modmanager/core/SloppyXMLParser.java b/src/main/java/net/vhati/modmanager/core/SloppyXMLParser.java index 0688c45..dfc2e28 100644 --- a/src/main/java/net/vhati/modmanager/core/SloppyXMLParser.java +++ b/src/main/java/net/vhati/modmanager/core/SloppyXMLParser.java @@ -28,7 +28,9 @@ import org.jdom2.input.JDOMParseException; * * Sloppiness: * Any closing tag, regardless of its name, closes the parent tag. - * is valid (but the extra dashes will be discarded). + * is valid. + * The example above will become two comments. Any extra dashes will + * be discarded. * --> can occur alone (discarded). * An attribute name can start right after the quote from a prior value. * Namespace prefixes for nodes and attributes are unique. @@ -109,9 +111,33 @@ public class SloppyXMLParser { factory.addContent( parentNode, factory.text( whitespace ) ); tmp = m.group( 2 ); - tmp = tmp.replaceAll( "^-+|(?<=-)-+|-+$", "" ); - Comment commentNode = factory.comment( tmp ); - factory.addContent( parentNode, commentNode ); + if ( tmp.length() == 0 ) { + factory.addContent( parentNode, factory.comment( "" ) ); + } + else { + Matcher splicedMatcher = Pattern.compile( "(\\s*)