jenkins-bot has submitted this change and it was merged. Change subject: Don't serialize HTML id attributes with Parsoid-like elt ids ......................................................................
Don't serialize HTML id attributes with Parsoid-like elt ids * To protect against client bugs that pass in parsoid-like element ids on the DOM, after applying data-parsoid on the DOM, strip any remaining element ids that might resembly parsoid-generated ones. * This should eliminate errors like the one reported in this diff: https://www.mediawiki.org/w/index.php?title=Wikimedia_Engineering/2014-15_Goals&diff=1468763&oldid=1449825 Change-Id: I303b8d8a6a5e8f8fc7471603219c7d59915bb9a7 --- M lib/mediawiki.WikitextSerializer.js M tests/parserTests.txt 2 files changed, 24 insertions(+), 0 deletions(-) Approvals: Arlolra: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/mediawiki.WikitextSerializer.js b/lib/mediawiki.WikitextSerializer.js index bc16198..56a2c3c 100644 --- a/lib/mediawiki.WikitextSerializer.js +++ b/lib/mediawiki.WikitextSerializer.js @@ -217,6 +217,14 @@ continue; } + // Ignore parsoid-like ids. They may have been left behind + // by clients and shouldn't be serialized. This can also happen + // in v2 API when there is no matching data-parsoid entry found + // for this id. + if (k === "id" && /^mw[\w-]{2,}$/.test(kv.v)) { + continue; + } + // Strip Parsoid-generated values // // FIXME: Given that we are currently escaping about/typeof keys diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 9db7448..06e11be 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -23776,6 +23776,22 @@ !! end !! test +HTML id attribute with Parsoid-like element ids should not be serialized to wikitext +!! options +parsoid=html2wt +!! html +<table id='mwAb'> +<td id='mwAc'>foo</td> +<td id='serialize-this'>bar</td> +</table> +!! wikitext +{| +|foo +| id="serialize-this" |bar +|} +!! end + +!! test WTS change modes !! options parsoid={ -- To view, visit https://gerrit.wikimedia.org/r/197656 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I303b8d8a6a5e8f8fc7471603219c7d59915bb9a7 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <[email protected]> Gerrit-Reviewer: Arlolra <[email protected]> Gerrit-Reviewer: Cscott <[email protected]> Gerrit-Reviewer: GWicke <[email protected]> Gerrit-Reviewer: Marcoil <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
