Go to file
Bartosz Dziewoński c1f4668806 Change CommentParser and ImmutableRange to use offsets in codepoints instead of bytes
The PHP DOM extension measures lengths and offsets in Unicode codepoints.
Our PHP code used UTF-8 bytes, causing some offsets to be slightly off.
Now it mostly uses Unicode codepoints as well (we're forced to use bytes
in a few places, because preg_match returns offsets in bytes).

In practice, this had no visible effect to the user. It caused the
markers `<span data-mw-comment-end="..."></span>` to be placed at
the end of their container instead of the correct position when the
timestamp contained multibyte characters (e.g. "ź" in Polish); but
the correct position is usually at the end of the container anyway.

In the test cases, the only difference is placing these markers before
a trailing line break inside `<p>...</p>` tags rather than before it.

The patch also accidentally fixes another bug, where element nodes
with no children (mostly <img>) were incorrectly excluded when calling
cloneContents(), because they were treated as if they were text nodes.

Change-Id: Iccdccf1078598f4b62cab96225e9c85a4c0e93ee
2021-09-27 19:04:16 +00:00
.phan Don't refer directly to PHP dom extension classes; avoid nonstandard behavior 2021-07-30 18:15:40 -04:00
i18n Merge "Change the "Watch this page" label to distinguish it from topic subscriptions" 2021-09-27 17:26:14 +00:00
images Apply an empty-state to pages with the new topic tool enabled 2021-08-04 18:46:28 -05:00
includes Change CommentParser and ImmutableRange to use offsets in codepoints instead of bytes 2021-09-27 19:04:16 +00:00
maintenance Defensive use of dynamic paths in maintenance script 2020-02-20 19:51:07 +01:00
modules Merge "Change the "Watch this page" label to distinguish it from topic subscriptions" 2021-09-27 17:26:14 +00:00
sql Minor cleanups in topic subscription code 2021-08-17 22:22:15 +02:00
tests Change CommentParser and ImmutableRange to use offsets in codepoints instead of bytes 2021-09-27 19:04:16 +00:00
.eslintignore build: Move eslint file list to .eslintignore 2021-03-04 18:09:34 +00:00
.eslintrc.json build: Updating eslint-config-wikimedia to 0.19.0 2021-03-13 10:51:31 +00:00
.gitignore Remove extra blank line from .gitignore file 2020-08-31 15:24:56 +01:00
.gitreview Add .gitreview 2019-10-09 21:18:34 +00:00
.phpcs.xml build: Updating mediawiki/mediawiki-codesniffer to 32.0.0 2020-10-29 10:53:01 +00:00
.stylelintrc.json Remove deprecated dt- classes 2021-03-23 12:39:34 +00:00
CODE_OF_CONDUCT.md build: Updating npm dependencies 2020-01-09 06:43:15 +00:00
composer.json build: Updating composer dependencies 2021-09-08 23:14:53 +00:00
COPYING Add required files for an extension 2019-10-10 19:42:56 +01:00
extension.json Change the "Watch this page" label to distinguish it from topic subscriptions 2021-09-21 11:44:06 +02:00
Gruntfile.js build: Move eslint file list to .eslintignore 2021-03-04 18:09:34 +00:00
package-lock.json build: Updating stylelint-config-wikimedia to 0.11.1 2021-09-04 19:36:49 +00:00
package.json build: Updating stylelint-config-wikimedia to 0.11.1 2021-09-04 19:36:49 +00:00