diff --git a/extension.json b/extension.json index 9fce6fcce..6dabe2bbd 100644 --- a/extension.json +++ b/extension.json @@ -68,6 +68,7 @@ "mediawiki.Uri", "mediawiki.util", "mediawiki.storage", + "mediawiki.String", "ext.visualEditor.core.utils.parsing" ], "messages": [ diff --git a/includes/CommentParser.php b/includes/CommentParser.php index 00587eb8c..9ed88690e 100644 --- a/includes/CommentParser.php +++ b/includes/CommentParser.php @@ -511,7 +511,7 @@ class CommentParser { ( $node = $node->previousSibling ) && $length < self::SIGNATURE_SCAN_LIMIT && $node !== $until ) { $sigNodes[] = $node; - $length += $node->textContent ? strlen( $node->textContent ) : 0; + $length += $node->textContent ? mb_strlen( $node->textContent ) : 0; if ( !( $node instanceof DOMElement ) ) { continue; } diff --git a/modules/Parser.js b/modules/Parser.js index 781027d53..b76b1a72b 100644 --- a/modules/Parser.js +++ b/modules/Parser.js @@ -7,6 +7,7 @@ var utils = require( './utils.js' ), + codePointLength = require( 'mediawiki.String' ).codePointLength, CommentItem = require( './CommentItem.js' ), HeadingItem = require( './HeadingItem.js' ), // Hooks::getLocalData() @@ -530,7 +531,7 @@ Parser.prototype.findSignature = function ( timestampNode, until ) { while ( ( node = node.previousSibling ) && length < data.signatureScanLimit && node !== until ) { sigNodes.push( node ); - length += ( node.textContent || '' ).length; + length += node.textContent ? codePointLength( node.textContent ) : 0; if ( node.nodeType !== Node.ELEMENT_NODE ) { continue; }