jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/394412 )
Change subject: T180930: Selser shouldn't reuse orig sep for autoinserted tags ...................................................................... T180930: Selser shouldn't reuse orig sep for autoinserted tags Change-Id: I76418f44bb078c5f70cf2ef6b7982dff58448491 --- M lib/html2wt/separators.js M tests/parserTests-blacklist.js 2 files changed, 21 insertions(+), 34 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/html2wt/separators.js b/lib/html2wt/separators.js index 0f341a8..9adc94f 100644 --- a/lib/html2wt/separators.js +++ b/lib/html2wt/separators.js @@ -462,6 +462,15 @@ return sep; } +// Serializing auto inserted content should invalidate the original separator +var handleAutoInserted = function(node) { + var dp = DU.getDataParsoid(node); + var dsr = Util.clone(dp.dsr); + if (dp.autoInsertedStart) { dsr[2] = null; } + if (dp.autoInsertedEnd) { dsr[3] = null; } + return dsr; +}; + /** * Emit a separator based on the collected (and merged) constraints * and existing separator text. Called when new output is triggered. @@ -500,7 +509,7 @@ prevNode.parentNode !== node && DU.getDataParsoid(prevNode.parentNode).dsr && DU.getDataParsoid(prevNode.parentNode).dsr[3] === 0) { - dsrA = DU.getDataParsoid(prevNode.parentNode).dsr; + dsrA = handleAutoInserted(prevNode.parentNode); } else if (prevNode.previousSibling && prevNode.previousSibling.nodeType === prevNode.ELEMENT_NODE && // FIXME: Not sure why we need this check because data-parsoid @@ -522,7 +531,7 @@ } } } else { - dsrA = DU.getDataParsoid(prevNode).dsr; + dsrA = handleAutoInserted(prevNode); } if (!dsrA) { @@ -570,7 +579,7 @@ // The top node could be a document fragment, which is not // an element, and so getDataParsoid will return `null`. - dsrB = DU.isElt(node) ? DU.getDataParsoid(node).dsr : null; + dsrB = DU.isElt(node) ? handleAutoInserted(node) : null; } // FIXME: Maybe we shouldn't set dsr in the dsr pass if both aren't valid? diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js index 9fa5877..d9f5409 100644 --- a/tests/parserTests-blacklist.js +++ b/tests/parserTests-blacklist.js @@ -1591,39 +1591,17 @@ add("selser", "HTML bullet list, closed tags (T7497) [[4,[2],3,0,0]]", "<ul><li>1ll4gfg</li><li>wnpb5dOne</li>\n<li>Two</li>\n</ul>"); add("selser", "HTML nested ordered list, open tags (T7497) [[2,3,4,[2,1],3]]", "<ol><li>1ph637d</li>\n<li>l97dbh</li><li>1lg6gmxTwo:\n<ol data-foobar=\"1pegvwc\">\n<li>Sub-one\n<li>Sub-two\n</ol>\n</ol>"); add("selser", "Fuzz testing: Parser13 [2]", "1s3ei1s\n{| \n| http://a|"); -add("selser", "Fuzz testing: Parser13 [[0,[[1]]]]", "{| \n| data-foobar=\"nmk8w6\" http: / a ||}"); -add("selser", "Fuzz testing: Parser13 [1]", "{| data-foobar=\"13wllqe\" \n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,2]]", "{|<!--1cxzpcg--> \n<!--qebzjb-->| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[4,2]]", "{|<!--bch54l--><!--14d1sbn-->\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,1]]", "{| \n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,2]]", "{| \n<!--l3hcbe-->| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,[1]]]", "{| \n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,[[1]]]]", "{|<!--13v70zv--> \n| data-foobar=\"cmzmng\" http: / a ||}"); -add("selser", "Fuzz testing: Parser13 [[4,[1]]]", "{|<!--mdbo58-->\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[4,0]]", "{|<!--mfod94-->\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,0]]", "{|<!--upaz27--> \n| http://a||}"); +add("selser", "Fuzz testing: Parser13 [1]", "{| data-foobar=\"13wllqe\" \n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[2,2]]", "{|<!--1cxzpcg--> \n<!--qebzjb-->| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[4,2]]", "{|<!--bch54l--><!--14d1sbn-->\n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[0,1]]", "{| \n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[0,2]]", "{| \n<!--l3hcbe-->| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[0,[1]]]", "{| \n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[4,[1]]]", "{|<!--mdbo58-->\n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[4,0]]", "{|<!--mfod94-->\n| http://a|\n|}"); +add("selser", "Fuzz testing: Parser13 [[2,0]]", "{|<!--upaz27--> \n| http://a|\n|}"); add("selser", "Fuzz testing: Parser16 [2]", "1jeb7ja\n{|\n!https://||||||"); -add("selser", "Fuzz testing: Parser16 [[0,[[0,2,0,0]]]]", "{|\n!https://\n!7nk0ln|||||||}"); -add("selser", "Fuzz testing: Parser16 [[0,[[3,4,0,0]]]]", "{|\n!18o2jid|||||}"); -add("selser", "Fuzz testing: Parser16 [[3,2]]", "{|<!--9co2pf-->\n!https://|||||||}"); -add("selser", "Fuzz testing: Parser16 [[0,1]]", "{|\n!https://|||||||}"); -add("selser", "Fuzz testing: Parser16 [[3,[2]]]", "{|<!--v1br0f-->\n!https://|||||||}"); -add("selser", "Fuzz testing: Parser16 [[0,[[1,1,1,0]]]]", "{|\n! data-foobar=\"1ypnx5s\" |https://|| data-foobar=\"lc27jn\" ||| data-foobar=\"14qvamm\" ||||}"); -add("selser", "Fuzz testing: Parser16 [1]", "{| data-foobar=\"1j1pbvp\"\n!https://|||||||}"); -add("selser", "Fuzz testing: Parser16 [[2,[1]]]", "{|<!--1g0ou56-->\n!https://|||||||}"); -add("selser", "Fuzz testing: Parser21 [[2,2]]", "{|<!--v1et9x-->\n<!--amz9p1-->! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [1]", "{| data-foobar=\"14162hx\"\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[4,[2]]]", "{|<!--14lxyyj--><!--1rwy9y6-->\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[3,[1]]]", "{|\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[0,[[[0,2,0],0,0]]]]", "{|\n! dcs53y<nowiki/>irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[2,[[3,0,0]]]]", "{|<!--hudhng-->\n\n||}"); -add("selser", "Fuzz testing: Parser21 [[0,[[[4,[4],0],0,0]]]]", "{|\n!3wg2o2[irc://{{ftp://a 686awo]\" onmouseover=\"alert('hello world');\"\n||}"); add("selser", "Fuzz testing: Parser21 [2]", "13y1bui\n{|\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n|"); -add("selser", "Fuzz testing: Parser21 [[2,[2]]]", "{|<!--1zrh54-->\n<!--jjroqc-->! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[0,[2]]]", "{|\n<!--1jdtwcn-->! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[0,[[[2,1,2],4,1]]]]", "{|\n!fliidg irc://{{ftp://a<nowiki/>mo67tl\" onmouseover=\"alert('hello world');\"\n!fllk05\n| data-foobar=\"3u8hle\" ||}"); -add("selser", "Fuzz testing: Parser21 [[3,[[2,0,0]]]]", "{|\n|n9v69n\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); -add("selser", "Fuzz testing: Parser21 [[3,1]]", "{|\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n||}"); add("selser", "Fuzz testing: Parser22 [[4],0,0]", "nr0us7\n\n{|"); add("selser", "Fuzz testing: Parser22 [1,2,2]", "http://===r:::https://b\n\nfa9uov\n\n1qnwe6o\n{|"); add("selser", "Fuzz testing: Parser22 [1,3,0]", "http://===r:::https://b\n{|"); -- To view, visit https://gerrit.wikimedia.org/r/394412 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I76418f44bb078c5f70cf2ef6b7982dff58448491 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org> Gerrit-Reviewer: Sbailey <sbai...@wikimedia.org> Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits