From 06c8354e321f2fc27fe913db27c33e940c78b508 Mon Sep 17 00:00:00 2001 From: Richard Van Tassel Date: Thu, 20 Feb 2025 19:36:28 -0500 Subject: [PATCH] Ignores closing tags of void elements, avoids pushing tags of void elements. --- OpenDreamClient/Interface/Html/HtmlParser.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenDreamClient/Interface/Html/HtmlParser.cs b/OpenDreamClient/Interface/Html/HtmlParser.cs index 6641c1294f..98f11e6a57 100644 --- a/OpenDreamClient/Interface/Html/HtmlParser.cs +++ b/OpenDreamClient/Interface/Html/HtmlParser.cs @@ -70,8 +70,13 @@ void PushCurrentText() { string tagType = attributes[0].ToLowerInvariant(); currentText.Clear(); + bool isSelfClosing = IsSelfClosing(tagType, attributes); if (closingTag) { - if (tags.Count == 0) { + if (isSelfClosing) { + // ignore closing tags of void elements since they don't + // do anything anyway. Should probably warn. + return; + } else if (tags.Count == 0) { Sawmill.Error("Unexpected closing tag"); return; } else if (tags.Peek() != tagType) { @@ -82,9 +87,9 @@ void PushCurrentText() { appendTo.Pop(); tags.Pop(); } else { - tags.Push(tagType); - - bool isSelfClosing = IsSelfClosing(tagType, attributes); + if (!isSelfClosing) { + tags.Push(tagType); + } appendTo.PushTag(new MarkupNode(tagType, null, ParseAttributes(attributes)), selfClosing: isSelfClosing); }