diff --git a/includes/CommentParser.php b/includes/CommentParser.php index 250beca6d..e563a2bac 100644 --- a/includes/CommentParser.php +++ b/includes/CommentParser.php @@ -600,7 +600,8 @@ class CommentParser { } if ( $event === 'leave' && $node !== $timestampNode ) { - $length += $node instanceof Text ? mb_strlen( $node->textContent ?? '' ) : 0; + $length += $node instanceof Text ? + mb_strlen( CommentUtils::htmlTrim( $node->textContent ?? '' ) ) : 0; } // Find the closest link before timestamp that links to the user's user page. diff --git a/modules/Parser.js b/modules/Parser.js index 2929598c4..c34325a88 100644 --- a/modules/Parser.js +++ b/modules/Parser.js @@ -587,7 +587,8 @@ Parser.prototype.findSignature = function ( timestampNode, until ) { } if ( event === 'leave' && node !== timestampNode ) { - length += node.nodeType === Node.TEXT_NODE ? codePointLength( node.textContent ) : 0; + length += node.nodeType === Node.TEXT_NODE ? + codePointLength( utils.htmlTrim( node.textContent ) ) : 0; } // Find the closest link before timestamp that links to the user's user page.