Skip to content

Fixes HtmlParser handling of XML comments and values containing spaces#2619

Open
PowerfulBacon wants to merge 4 commits into
OpenDreamProject:masterfrom
PowerfulBacon:Fixes-HtmlParser-errors-when-handling-comments
Open

Fixes HtmlParser handling of XML comments and values containing spaces#2619
PowerfulBacon wants to merge 4 commits into
OpenDreamProject:masterfrom
PowerfulBacon:Fixes-HtmlParser-errors-when-handling-comments

Conversation

@PowerfulBacon

Copy link
Copy Markdown
Contributor

The HTML parser currently expects closing tags to match opening tags. This is a problem with comment nodes, as it pushes !-- to the stack, and expects !--/>, while the closing tag for comments is actually -->.

When a comment tag is encountered, the reader will totally ignore it and it won't be pushed to the formatted message at all. By default, the reader will read the entire comment tag <!-- this text will be included -->, however if the comment tag contains the > symbol, it won't be fully captured so I added SkipComment to handle that scenario.

The result is that the warnings in the console no longer occur when parsing HTML with comments.

image image image

(The empty nodes are new-line tags, which should probably be limited to a single one without
tags, but that's a different issue).

Also handling the situation that might break it nicely:

image image

Since the chat uses a browser window anyway, this has no visible effect on the chat but it stops an error in the console and this might become more important for maptext parsing, which is where the custom HTML parsing will have the most impact I think.

@boring-cyborg boring-cyborg Bot added the Client Involves the OpenDream client label Jun 7, 2026
@github-actions github-actions Bot added the size/S label Jun 7, 2026
@PowerfulBacon

PowerfulBacon commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Found another bug here, the string img class=' icon icon-floor' src='asset.e58c1d7b547c4efe06f91a20a3f7266f.png' is incorrectly handled

image

Edit: Fixed

Note that attributes not wrapped in " or ' are not valid in HTML, but will be matched by this anyway (example foo=5)

image image image

@PowerfulBacon PowerfulBacon changed the title Fixes HtmlParser handling of XML comments Fixes HtmlParser handling of XML comments and classes with spaces in them Jun 7, 2026
@PowerfulBacon PowerfulBacon changed the title Fixes HtmlParser handling of XML comments and classes with spaces in them Fixes HtmlParser handling of XML comments and values containing spaces Jun 7, 2026
Comment thread OpenDreamClient/Interface/Html/HtmlParser.cs Fixed
Comment thread OpenDreamClient/Interface/Html/HtmlParser.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Client Involves the OpenDream client size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants