Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93919
Change subject: (Bug 56646) Edge-case bug fix in migrateTrailingNLs dom pass
......................................................................
(Bug 56646) Edge-case bug fix in migrateTrailingNLs dom pass
* migrateTrailingNLs had a bunch of tests for when to migrate
trailing newlines across meta tags. But, it never really
tested for zero-width tsr. This cause a newline to get migrated
across a <meta placeholder> tag that gets inserted for missing
images (which is a bug and introduced an off-by-1 error in DSR
computation of the parent node). This bug showed up in our local
testing because the images referenced by our local copies of
the BO page are all non-existent locally.
So, in production, this bug would have only surface when a missing
image happened to end a paragraph and had newlines preceding it
and so, really an edge case.
* That said, the bunch of special-case tests should not be necessary
anymore -- they were probably present in earlier versions of the
code and are probably fragile.
No change in parser tests -- should I concoct a test for this?
* But, since is a more radical change, this should be put through
the paces via roundtrip testing.
Change-Id: I92710ce547906c0fc7eb531aebb8b5d3434657ce
---
M js/lib/dom.migrateTrailingNLs.js
M js/lib/mediawiki.WikitextSerializer.js
2 files changed, 3 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/19/93919/1
diff --git a/js/lib/dom.migrateTrailingNLs.js b/js/lib/dom.migrateTrailingNLs.js
index f07cb56..19893a2 100644
--- a/js/lib/dom.migrateTrailingNLs.js
+++ b/js/lib/dom.migrateTrailingNLs.js
@@ -67,35 +67,10 @@
partialContent = false,
n = elt.lastChild;
- // We can migrate trailing newline-containing separators
- // across meta tags as long as the metas:
- // - are not literal html metas (found in wikitext)
- // - are not mw:PageProp (cannot cross page-property boundary
- // - are not mw:Includes/* (cannot cross <*include*> boundary)
- // - are not ext/tpl start/end markers (cannot cross ext/tpl
boundary)
- // - are not ext placeholder markers (cannot cross ext
boundaries)
- while (n && DU.hasNodeName(n, "meta") &&
!DU.isLiteralHTMLNode(n)) {
- var prop = n.getAttribute("property"),
- type = n.getAttribute("typeof");
-
- if (prop && prop.match(/mw:PageProp/)) {
- break;
- }
-
- if (type && (DU.isTplMetaType(type) ||
type.match(/(?:^|\s)(mw:Includes|mw:Extension\/)/))) {
- break;
- }
-
+ // We can migrate trailing newlines across nodes that have
zero-wikitext-width.
+ while (n && DU.isElt(n) && hasZeroWidthWT(n)) {
migrationBarrier = n;
n = n.previousSibling;
- }
-
- // We can migrate trailing newlines across nodes that have
zero-wikitext-width.
- if (n && !DU.hasNodeName(n, "meta")) {
- while (n && DU.isElt(n) && hasZeroWidthWT(n)) {
- migrationBarrier = n;
- n = n.previousSibling;
- }
}
// Find nodes that need to be migrated out:
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index 11293bf..84401f2 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -4247,7 +4247,7 @@
var out = state.getOrigSrc(dp.dsr[0],
dp.dsr[1]);
// console.warn("USED ORIG");
- this.trace("ORIG-src:", out);
+ this.trace("ORIG-src with DSR[",
dp.dsr[0], dp.dsr[1], "]", out);
cb(out, node);
// Skip over encapsulated content since
it has already been serialized
--
To view, visit https://gerrit.wikimedia.org/r/93919
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I92710ce547906c0fc7eb531aebb8b5d3434657ce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits