GWicke has submitted this change and it was merged.

Change subject: Correctly detect modified tokens (bug from commit 46119efb).
......................................................................


Correctly detect modified tokens (bug from commit 46119efb).

* The wikitext: "[a = {{echo|b}}]" was not being properly parsed
  and consequently RT-ed because AttributeExpander was ignoring
  modified tokens (from expanded attributes).

* Fixed and verified.

* The page en:Gigabarrel from which this test case was extracted
  now RTs correctly.

* No change in parser test results -- worth adding a new test.

Change-Id: I71ecf966e6dad9ed874f2cdfb4a8a5d91ec86d2f
---
M js/lib/ext.core.AttributeExpander.js
1 file changed, 7 insertions(+), 7 deletions(-)

Approvals:
  GWicke: Verified; Looks good to me, approved



diff --git a/js/lib/ext.core.AttributeExpander.js 
b/js/lib/ext.core.AttributeExpander.js
index 2db92ea..a6c0ed3 100644
--- a/js/lib/ext.core.AttributeExpander.js
+++ b/js/lib/ext.core.AttributeExpander.js
@@ -76,10 +76,6 @@
                }
 
                if (newK) {
-                       if (newK !== a.k) {
-                               modified = true;
-                       }
-
                        var contentType = "objectAttrKey"; // default
                        if (a.k.constructor === Array) {
                                if ( newK.constructor === String && newK.match( 
/mw\:maybeContent/ ) ) {
@@ -125,11 +121,15 @@
                                                metaTokens.push( 
Util.makeTplAffectedMeta(contentType, newK, updatedK) );
                                        }
                                }
+                       } else if (newK !== a.k) {
+                               modified = true;
                        }
+
 
                        // We have a string key and potentially expanded value.
                        // Check if the value came from a template/extension 
expansion.
-                       if (a.v.constructor === Array && newK.constructor === 
String) {
+                       if (newK.constructor === String && a.v.constructor === 
Array) {
+                               modified = true;
                                if (newK.match( /mw\:maybeContent/ ) ) {
                                        // For mw:maybeContent attributes, at 
this point, we do not really know
                                        // what this attribute represents.
@@ -159,7 +159,6 @@
                                                ]);
                                                newAttrs.push( kv );
                                        }
-                                       modified = true;
                                } else if (!newK.match(/^mw:/)) {
                                        updatedV = Util.stripMetaTags( 
newAttrs[i].v, this.options.wrapTemplates );
                                        newAttrs[i].v = updatedV.value;
@@ -168,8 +167,9 @@
                                                producerObjType = metaObjType;
                                                metaTokens.push( 
Util.makeTplAffectedMeta("objectAttrVal", newK, updatedV) );
                                        }
-                                       modified = true;
                                }
+                       } else if (newAttrs[i].v !== a.v) {
+                               modified = true;
                        }
                }
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I71ecf966e6dad9ed874f2cdfb4a8a5d91ec86d2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to