Page MenuHomePhabricator

DiscussionTools doesn't automatically close open html comments (-->) when posting
Open, LowPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  1. Leave a message on any discussion and attach <!-- at the end
  2. Open a new topic and leave a message

What happens?:

Your message disappears, and if you click on the previous message, it will be displayed along with the next message

What should have happened instead?:

_

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

I renamed this task from If a The end of a paragraph with <!--, all subsequent paragraphs are merged into this one to If a The end of a paragraph with <!--, all subsequent paragraphs are merged into this one, & If a previous message ends with <!--, using new topics to open a new topic causes an exception.May 1 2023, 6:44 AM
Peachey88 renamed this task from If a The end of a paragraph with <!--, all subsequent paragraphs are merged into this one, & If a previous message ends with <!--, using new topics to open a new topic causes an exception to DiscussionTools doesn't automatically close open html comments (-->) when posting.May 1 2023, 8:05 AM
MSantos moved this task from Needs Triage to Feature requests on the Parsoid board.

I think we can be a little more specific and make this a low-priority feature request. When Parsoid handles an unclosed comment in --wt2wt mode, it certainly adds the close comment tag:

$ echo 'Foo <!-- Bar' | php bin/parse.php --wt2wt
Foo <!-- Bar
-->

But what I suspect is happening is that parsoid in selser mode tries to avoid the dirty diff and suppresses the final --> which wasn't present in the original wikitext. Then the particular method that DiscussionTools is using to append the comment to the text ends up failing because the comment isn't balanced. This is fundamentally the same issue as if we had an unclosed <b> tag or some such at the end of the document; we need to balance the content before we append new content and/or treat the final node of the document tree as "changed" for selser purposes when we do an append at the end of the document.