diff --git a/Core.Tests/Parser/ParsingTests.cs b/Core.Tests/Parser/ParsingTests.cs index f3098f8..2c8f6bc 100644 --- a/Core.Tests/Parser/ParsingTests.cs +++ b/Core.Tests/Parser/ParsingTests.cs @@ -222,6 +222,21 @@ public void BadClosingTag () result.AssertDiagnosticCount (2); } + [Test] + public void MalformedSelfClosingTag () + { + var parser = new XmlTreeParser (CreateRootState ()); + var result = parser.Parse (@"", + + () => { + parser.AssertStateIs (); + }); + + parser.AssertDiagnostics ( + (XmlCoreDiagnostics.MalformedSelfClosingTag, 7, 0) + ); + } + [Test] public void MismatchedElementNameWithNamespace () { diff --git a/Core/Parser/XmlTagState.cs b/Core/Parser/XmlTagState.cs index d9c98e3..9a1869f 100644 --- a/Core/Parser/XmlTagState.cs +++ b/Core/Parser/XmlTagState.cs @@ -41,7 +41,7 @@ public class XmlTagState : XmlParserState const int ATTEMPT_RECOVERY = 1; const int RECOVERY_FOUND_WHITESPACE = 2; - const int MAYBE_SELF_CLOSING = 2; + const int MAYBE_SELF_CLOSING = 3; const int FREE = 0; readonly XmlAttributeState AttributeState; @@ -139,6 +139,11 @@ public XmlTagState (XmlAttributeState attributeState, XmlNameState nameState) return null; } + if (context.StateTag == MAYBE_SELF_CLOSING) { + context.Diagnostics?.Add (XmlCoreDiagnostics.MalformedSelfClosingTag, context.Position, c); + return null; + } + if (context.StateTag == ATTEMPT_RECOVERY) { if (XmlChar.IsWhitespace (c)) { context.StateTag = RECOVERY_FOUND_WHITESPACE;