Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/212215

Change subject: Fix crasher in domdiff
......................................................................

Fix crasher in domdiff

* 482083b48b88cc4bb53a61050438af0b8e0bf61e added specialized domdiff
  comparison for 'id' properties in data-mw.

  However, 'id' properties can show up for other reasons besides
  being element-ids added for <ref> bodies.

* Ex: {{Foobar|id=something}} will get a "id": {"wt": "something"}
  as part of the "params" property in data-mw. This key broke
  dom-diff.

* This patch adds safeguards to verify that id value is a string
  and that the DOM lookups were successful.

  Alternatively, we should special case the 'id' comparison for
  <ref> data-mw only. Maybe?

* Fixes rtselser and roundtrip-test crashers for enwiki:John_Carnell

Change-Id: I1b58412749a6d35986ba8ecb37d9a3d90e6a8857
---
M lib/mediawiki.DOMDiff.js
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/15/212215/1

diff --git a/lib/mediawiki.DOMDiff.js b/lib/mediawiki.DOMDiff.js
index 55663a2..dace53e 100644
--- a/lib/mediawiki.DOMDiff.js
+++ b/lib/mediawiki.DOMDiff.js
@@ -99,14 +99,24 @@
                        }
                } else if (vA.constructor !== vB.constructor) {
                        return false;
-               } else if (kA === 'id') {
+               } else if (kA === 'id' && typeof vA === 'string' && typeof vB 
=== 'string') {
+                       // For transclusions like {{foobar|id=something}}, the 
data-mw for this
+                       // node will have entries like {"id" : {"wt": 
"something"} } in the
+                       // "params" property of data-mw. We are interested in 
string values for
+                       // the "id" param.
+                       //
                        // For <refs> in <references> the element id can refer 
to the
                        // global DOM, not the owner document DOM.
                        var htmlA = nodeA.ownerDocument.getElementById(vA)
                                || this.domA.getElementById(vA);
                        var htmlB = nodeB.ownerDocument.getElementById(vB)
                                || this.domB.getElementById(vB);
-                       if (!this.treeEquals(htmlA, htmlB, true)) {
+
+                       if (htmlA && htmlB && !this.treeEquals(htmlA, htmlB, 
true)) {
+                               return false;
+                       } else if ((!htmlA || !htmlB) && vA !== vB) {
+                               // Fall back to default comparisons
+                               // SSS FIXME: Do we need warnings logged here?
                                return false;
                        }
                } else if (kA === 'html') {

-- 
To view, visit https://gerrit.wikimedia.org/r/212215
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b58412749a6d35986ba8ecb37d9a3d90e6a8857
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to