Ignore HTML comments which are more than two lines from a reply

Bug: T264026
Change-Id: I989132d7599a7fa156dba46d87a9ed4b76322c0c
This commit is contained in:
Ed Sanders 2020-09-28 18:32:42 +01:00
parent 2eb5f853d8
commit 6b8312e610
4 changed files with 32 additions and 4 deletions

View file

@ -148,7 +148,10 @@ class CommentModifier {
$pointer->nextSibling instanceof DOMComment ||
(
$pointer->nextSibling instanceof DOMText &&
CommentUtils::htmlTrim( $pointer->nextSibling->nodeValue ) === ''
CommentUtils::htmlTrim( $pointer->nextSibling->nodeValue ) === '' &&
// If more that two lines of whitespace are detected, the following HTML
// comments are not considered to be part of the reply (T264026)
!preg_match( '/(\r?\n){2,}/', $pointer->nextSibling->nodeValue )
)
)
) {

View file

@ -139,7 +139,10 @@ function addListItem( comment ) {
pointer.nextSibling.nodeType === Node.COMMENT_NODE ||
(
pointer.nextSibling.nodeType === Node.TEXT_NODE &&
utils.htmlTrim( pointer.nextSibling.textContent ) === ''
utils.htmlTrim( pointer.nextSibling.textContent ) === '' &&
// If more that two lines of whitespace are detected, the following HTML
// comments are not considered to be part of the reply (T264026)
!/(\r?\n){2,}/.test( pointer.nextSibling.textContent )
)
)
) {

View file

@ -5,4 +5,15 @@
<p>hello <!-- Template:Unsigned --><small class="autosigned"><span typeof="mw:Entity">&nbsp;</span>Preceding <a rel="mw:WikiLink/Interwiki" href="https://en.wikipedia.org/wiki/Signatures" title="wikipedia:Signatures">unsigned</a> comment added by <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex#top" title="User talk:Matma Rex">talk</a><a rel="mw:WikiLink" href="./Special:Contributions/Matma_Rex" title="Special:Contributions/Matma Rex">contribs</a>) 18:43, 22 July 2020 (UTC)</small></p> <!--Autosigned by SineBot--><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:43:00.000Z|0</dd></dl>
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:41, 22 July 2020 (UTC) <!-- xxx --></p>
<ul><li>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:42, 22 July 2020 (UTC)<!-- xxx --><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:42:00.000Z|0</dd></dl></li></ul><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:41:00.000Z|0</dd></dl></body></html>
<ul><li>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:42, 22 July 2020 (UTC)<!-- xxx --><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:42:00.000Z|0</dd></dl></li></ul><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:41:00.000Z|0</dd></dl>
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:44, 22 July 2020 (UTC) </p>
<!-- Above comment added by announce-bot --><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:44:00.000Z|0</dd></dl>
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:45, 22 July 2020 (UTC) </p><dl><dd data-parsoid="{}">Reply to Matma Rex|2020-07-22T18:45:00.000Z|0</dd></dl>
<!-- No replies below this line -->
<p>Footer</p>
</body></html>

View file

@ -5,4 +5,15 @@
<p>hello <!-- Template:Unsigned --><small class="autosigned"><span typeof="mw:Entity">&nbsp;</span>Preceding <a rel="mw:WikiLink/Interwiki" href="https://en.wikipedia.org/wiki/Signatures" title="wikipedia:Signatures">unsigned</a> comment added by <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex#top" title="User talk:Matma Rex">talk</a><a rel="mw:WikiLink" href="./Special:Contributions/Matma_Rex" title="Special:Contributions/Matma Rex">contribs</a>) 18:43, 22 July 2020 (UTC)</small></p> <!--Autosigned by SineBot-->
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:41, 22 July 2020 (UTC) <!-- xxx --></p>
<ul><li>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:42, 22 July 2020 (UTC)<!-- xxx --></li></ul></body></html>
<ul><li>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:42, 22 July 2020 (UTC)<!-- xxx --></li></ul>
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:44, 22 July 2020 (UTC) </p>
<!-- Above comment added by announce-bot -->
<p>hello <a rel="mw:WikiLink" href="./User:Matma_Rex" title="User:Matma Rex">Matma Rex</a> (<a rel="mw:WikiLink" href="./User_talk:Matma_Rex" title="User talk:Matma Rex"><font color="green"><i>talk</i></font></a>) 18:45, 22 July 2020 (UTC) </p>
<!-- No replies below this line -->
<p>Footer</p>
</body></html>