jenkins-bot has submitted this change and it was merged. Change subject: Content on table start / row is all attributes ......................................................................
Content on table start / row is all attributes * Fixes the regression introduced in I0e6e597e2f4eb9dfe0ded34f92aa15a83338229e * enwiki/Trinity_(nuclear_test)?oldid=679523451 rt's without semantic diffs now. * Adds a test to show that the php parser aborts table cell attribute parsing on first encounter of `[[`. Parsoid matches this behaviour but roundtrips additional `|` on the line with nowikis. The escape code needs to be updated to account for the presence of the brackets but currently doesn't have access to all text on a line. That's being worked on in Ie8dbac6b968f3f4e3792f0e7d1db7cf2aacde80c. Bug: T95131 Change-Id: I0646442d27b863c6653491c43c319c3d87cf9ca5 --- M lib/mediawiki.tokenizer.utils.js M lib/pegTokenizer.pegjs.txt M tests/parserTests-blacklist.js M tests/parserTests.txt 4 files changed, 75 insertions(+), 42 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/mediawiki.tokenizer.utils.js b/lib/mediawiki.tokenizer.utils.js index 9847bf0..5026e16 100644 --- a/lib/mediawiki.tokenizer.utils.js +++ b/lib/mediawiki.tokenizer.utils.js @@ -173,7 +173,7 @@ */ inlineBreaks: function(input, pos, stops) { var c = input[pos]; - if (!/[=|!\}\{:\r\n\]<]/.test(c)) { + if (!/[=|!{}:\r\n[\]<]/.test(c)) { return false; } @@ -190,34 +190,34 @@ case '|': return stops.onStack('pipe') || counters.linkdesc || - counters.tableCellArg || + stops.onStack('tableCellArg') || (stops.onStack('table') && ( pos < input.length - 1 && /[}|]/.test(input[pos + 1]))); + case '!': + return stops.onStack('th') !== false && + !stops.onCount('templatedepth') && + input[pos + 1] === "!"; case '{': // {{!}} pipe templates.. return ( - ((stops.onStack('pipe') || counters.tableCellArg) && + ((stops.onStack('pipe') || stops.onStack('tableCellArg')) && !counters.template && input.substr(pos, 5) === '{{!}}') || (stops.onStack('table') && input.substr(pos, 10) === '{{!}}{{!}}') ) && input.substr(pos, 5) === '{{!}}'; - case "!": - return stops.onStack('th') !== false && - !stops.onCount('templatedepth') && - input[pos + 1] === "!"; - case "}": + case '}': return counters.template && input[pos + 1] === "}"; - case ":": + case ':': return counters.colon && !stops.onStack('extlink') && !stops.onCount('templatedepth') && !counters.linkdesc; - case "\r": + case '\r': return stops.onStack('table') && /\r\n?\s*[!|]/.test(input.substr(pos)); - case "\n": + case '\n': // The code below is just a manual / efficient // version of this check. // @@ -246,16 +246,22 @@ } } return false; - case "]": + case '[': + // This is a special case in php's doTableStuff, added in + // response to T2553. If it encounters a `[[`, it bails on + // parsing attributes and interprets it all as content. + return stops.onStack('tableCellArg') && + input.substr(pos, 2) === '[['; + case ']': return stops.onStack('extlink') || (counters.linkdesc && input[pos + 1] === ']'); - case "<": + case '<': return (counters.pre && input.substr(pos, 6) === '<pre>') || (counters.noinclude && input.substr(pos, 12) === '</noinclude>') || (counters.includeonly && input.substr(pos, 14) === '</includeonly>') || (counters.onlyinclude && input.substr(pos, 14) === '</onlyinclude>'); default: - return false; + throw new Error('Unhandled case!'); } }, diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt index ecfbf4d..c32ae2a 100644 --- a/lib/pegTokenizer.pegjs.txt +++ b/lib/pegTokenizer.pegjs.txt @@ -1291,16 +1291,15 @@ // They are normally not matched by the table_attribute_name. broken_table_attribute_name_char = c:[\0/=>"'] { return new KV(c, ''); } -// Same as generic_attribute_name, except for accepting tags found here. +// Same as generic_attribute_name, except for accepting tags and wikilinks. // (That doesn't make sense (ie. match php) in the generic case.) -// We also give a chance to break on !|, and \[ is to avoid eating links. -// (See, BUG 553: link with two variables in a piped link) +// We also give a chance to break on !, |, and \[ (see T2553). table_attribute_name = r:( $[^ \t\r\n\0/=>"'<&{}\-!|\[]+ / !inline_breaks - !wikilink // \0/=>"' is the html5 attribute name set we do not want. - t:( directive + t:( $wikilink + / directive // Accept insane tags-inside-attributes as attribute names. // The sanitizer will strip and shadow them for roundtripping. // Example: <hiddentext>generated with.. </hiddentext> @@ -1567,6 +1566,7 @@ return sc; } +// FIXME: Not sure if we want to support it, but this should allow columns. table_caption_tag // avoid recursion via nested_block_in_table = ! { return stops.onStack('tableDataBlock'); } @@ -1722,12 +1722,12 @@ * match if followed by double pipe (row-based syntax). */ row_syntax_table_args - = & { return stops.inc('tableCellArg'); } + = & { return stops.push('tableCellArg', true); } as:table_attributes s:space* p:pipe !pipe { - stops.dec('tableCellArg'); + stops.pop('tableCellArg'); return [as, s, p]; } - / & { return stops.dec('tableCellArg'); } + / & { return stops.pop('tableCellArg'); } /******************************************************************* diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js index 99f3932..b7a4961 100644 --- a/tests/parserTests-blacklist.js +++ b/tests/parserTests-blacklist.js @@ -106,7 +106,6 @@ add("wt2html", "Template with invalid target containing unclosed tag", "<p data-parsoid='{\"dsr\":[0,49,0,0]}'>{{a<b data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[3,49,3,0]}'>|<span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[7,19,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}'>foo</span>|<span about=\"#mwt3\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[20,30,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"a\"}},\"i\":0}}]}'>a</span>=<span about=\"#mwt4\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]],\"dsr\":[31,41,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"b\"}},\"i\":0}}]}'>b</span>|a =b}}</b></p>"); add("wt2html", "Template with invalid target containing wikilink", "<p data-parsoid='{\"dsr\":[0,17,0,0]}'>{{<a rel=\"mw:WikiLink\" href=\"./Main_Page\" title=\"Main Page\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main Page\"},\"dsr\":[2,15,2,2]}'>Main Page</a>}}</p>"); add("wt2html", "Template with complex arguments", "<p data-parsoid='{\"dsr\":[0,106,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Template:Complextemplate\" title=\"Template:Complextemplate\" about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Template:Complextemplate\"},\"sa\":{\"href\":\"Template:complextemplate\"},\"dsr\":[0,106,null,null],\"pi\":[[{\"k\":\"param\",\"named\":true,\"spc\":[\"\\n \",\" \",\"\",\"\"]},{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"complextemplate\",\"href\":\"./Template:Complextemplate\"},\"params\":{\"1\":{\"wt\":\"[[Template:complextemplate|link]]\"},\"param\":{\"wt\":\"{{ templateasargtest |\\n templ = simple }}\"}},\"i\":0}}]}'>link</a><span about=\"#mwt1\"> This is a test template with parameter (test)</span></p>"); -add("wt2html", "BUG 553: link with two variables in a piped link", "<table data-parsoid='{\"dsr\":[0,26,2,2]}'>\n<tbody data-parsoid='{\"dsr\":[3,24,0,0]}'><tr data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,23,0,0]}'><td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,23,1,0]}'>[[<span about=\"#mwt5\" typeof=\"mw:Param\" data-parsoid='{\"dsr\":[6,13,null,null],\"src\":\"{{{1}}}\"}'>{{{1}}}</span>|<span about=\"#mwt2\" typeof=\"mw:Param\" data-parsoid='{\"dsr\":[14,21,null,null],\"src\":\"{{{2}}}\"}'>{{{2}}}</span>]]</td></tr>\n</tbody></table>"); add("wt2html", "Template infinite loop", "<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[0,9,null,null],\"pi\":[[]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"loop1\",\"href\":\"./Template:Loop1\"},\"params\":{},\"i\":0}}]}'></span>"); add("wt2html", "Template with targets containing wikilinks", "<p data-parsoid='{\"dsr\":[0,11,0,0]}'>{{<a rel=\"mw:WikiLink\" href=\"./Foo\" title=\"Foo\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Foo\"},\"sa\":{\"href\":\"foo\"},\"dsr\":[2,9,2,2]}'>foo</a>}}</p>\n\n<p data-parsoid='{\"dsr\":[13,33,0,0]}'>{{<a typeof=\"mw:ExpandedAttrs\" about=\"#mwt4\" rel=\"mw:WikiLink\" href=\"./Foo\" title=\"Foo\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Foo\"},\"sa\":{\"href\":\"{{echo|foo}}\"},\"dsr\":[15,31,null,null]}' data-mw='{\"attribs\":[[{\"txt\":\"href\"},{\"html\":\"<span about=\\\"#mwt3\\\" typeof=\\\"mw:Transclusion\\\" data-parsoid=\\\"{&quot;pi&quot;:[[{&quot;k&quot;:&quot;1&quot;,&quot;spc&quot;:[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]}]],&quot;dsr&quot;:[17,29,null,null]}\\\" data-mw=\\\"{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo&quot;}},&quot;i&quot;:0}}]}\\\">foo</span>\"}]]}'>foo</a>}}</p>\n\n<p data-parsoid='{\"dsr\":[35,55,0,0]}'><span typeof=\"mw:Transclusion mw:Placeholder\" about=\"#mwt5\" id=\"mwt5\" data-parsoid='{\"dsr\":[35,55,null,null],\"pi\":[[]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"{{echo|[[foo}}]]\"},\"params\":{},\"i\":0}}]}'>Warning: Page/template fetching disabled, and no cache for Template:[[foo]]</span></p>"); add("wt2html", "int keyword", "<p about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[0,45,0,0],\"pi\":[[{\"k\":\"1\",\"spc\":[\"\",\"\",\"\",\"\"]},{\"k\":\"2\",\"spc\":[\"\",\"\",\"\",\"\"]}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"int:youhavenewmessages\",\"function\":\"int\"},\"params\":{\"1\":{\"wt\":\"lots of money\"},\"2\":{\"wt\":\"not!\"}},\"i\":0}}]}'>Parser function implementation for pf_int missing in Parsoid.</p>"); @@ -308,7 +307,6 @@ add("wt2html", "2. Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)", "<p data-parsoid='{\"dsr\":[0,4,0,0]}'><span typeof=\"mw:Nowiki\" data-parsoid='{\"src\":\"{{}}\",\"dsr\":[0,4,0,0]}'>{{}}</span></p>"); add("wt2html", "1. Parsoid-only: Don't wrap broken template tags in <nowiki> on wt2wt (Bug 42353)", "<p data-parsoid='{\"dsr\":[0,4,0,0]}'><span typeof=\"mw:Nowiki\" data-parsoid='{\"src\":\"}}{{\",\"dsr\":[0,4,0,0]}'>}}{{</span></p>"); add("wt2html", "Empty table rows go away", "<table data-parsoid='{\"dsr\":[0,39,2,2]}'>\n<tbody data-parsoid='{\"dsr\":[3,37,0,0]}'><tr data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,18,0,0]}'><td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,10,1,0]}'> Hello</td>\n<td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[11,18,1,0]}'> there</td></tr>\n<tr class=\"foo\" data-parsoid='{\"startTagSrc\":\"|-\",\"autoInsertedEnd\":true,\"dsr\":[19,33,14,0]}'></tr>\n<tr data-parsoid='{\"startTagSrc\":\"|-\",\"autoInsertedEnd\":true,\"dsr\":[34,36,2,0]}'></tr>\n</tbody></table>"); -add("wt2html", "RT-ed inter-element separators should be valid separators", "<p data-parsoid='{\"fostered\":true,\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[0,0]}'><a rel=\"mw:WikiLink\" href=\"./Foo\" title=\"Foo\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Foo\"},\"sa\":{\"href\":\"foo\"},\"autoInsertedEnd\":true,\"dsr\":[6,13,2,0]}'>foo</a></p><table data-parsoid='{\"dsr\":[0,16,2,2]}'>\n<tbody data-parsoid='{\"dsr\":[3,14,0,0]}'><tr data-parsoid='{\"startTagSrc\":\"|-\",\"autoInsertedEnd\":true,\"dsr\":[3,12,2,0]}'></tr> \n</tbody></table>"); // Blacklist for wt2wt @@ -353,6 +351,7 @@ add("wt2wt", "Template with invalid target containing wikilink", "<nowiki>{{</nowiki>[[Main Page]]<nowiki>}}</nowiki>\n"); add("wt2wt", "Template with argument in separate line", "{{templateasargtest |\n templ = simple }}"); add("wt2wt", "BUG 553: link with two variables in a piped link", "{|\n|[[{{{1}}}<nowiki>|</nowiki>{{{2}}}]]\n|}"); +add("wt2wt", "Abort table cell attribute parsing on wikilink", "{|\n| testing [[one|two]]<nowiki> | three </nowiki>|| four\n| testing one two | three || four\n|}"); add("wt2wt", "Template with targets containing wikilinks", "<nowiki>{{</nowiki>[[foo]]<nowiki>}}</nowiki>\n\n<nowiki>{{</nowiki>[[{{echo|foo}}]]<nowiki>}}</nowiki>\n\n{{{{echo|[[foo}}]]}}\n"); add("wt2wt", "2. includeonly in html attr value", "<span id=\"<noinclude>v1</noinclude><includeonly>v2</includeonly>\">bar</span>\n<span id=\"<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>\">bar</span>\n"); add("wt2wt", "1. Table tag in SOL posn. should get reparsed correctly with valid TSR", "{{echo|}}\n{| width=\"100%\"\n|foo\n|}"); @@ -416,7 +415,6 @@ add("wt2wt", "HTML tag with broken attribute value quoting", "<span title=\"Hello world\">Foo</span>\n"); add("wt2wt", "Table with broken attribute value quoting", "{|\n| title=\"Hello world\" |Foo\n|}"); add("wt2wt", "Table with broken attribute value quoting on consecutive lines", "{|\n| title=\"Hello world\" |Foo\n| style=\"color:red\" |Bar\n|}"); -add("wt2wt", "RT-ed inter-element separators should be valid separators", "[[foo]]\n{|\n|- \n|}"); add("wt2wt", "Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out", "{|\n|<small>foo\n\nbar\n|}\n\n{|\n|<small>foo<small>\n|}"); add("wt2wt", "Empty TD followed by TD with tpl-generated attribute", "{|\n|-\n|\n| {{echo|style='color:red'}} |foo\n|}"); add("wt2wt", "Improperly nested inline or quotes tags with whitespace in between", "<span> <s>x</span> </s>\n''' ''x'''''<nowiki/>'' ''\n"); @@ -495,6 +493,8 @@ add("html2html", "Template with invalid target containing wikilink", "<p data-parsoid='{\"dsr\":[0,17,0,0]}'>{{<a rel=\"mw:WikiLink\" href=\"./Main_Page\" title=\"Main Page\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main Page\"},\"dsr\":[2,15,2,2]}'>Main Page</a>}}</p>\n"); add("html2html", "Template unnamed parameter", "<p data-parsoid='{\"dsr\":[0,32,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main Page\"},\"dsr\":[0,32,17,2]}'>the main page</a></p>\n"); add("html2html", "Template with complex arguments", "<p data-parsoid='{\"dsr\":[0,84,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Template:Complextemplate\" title=\"Wiki/Template:Complextemplate\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Template:Complextemplate\"},\"sa\":{\"href\":\"wiki/Template:Complextemplate\"},\"dsr\":[0,38,32,2]}'>link</a> This is a test template with parameter (test)</p>\n"); +add("html2html", "BUG 553: link with two variables in a piped link", "<table data-parsoid='{\"dsr\":[0,43,2,2]}'>\n<tbody data-parsoid='{\"dsr\":[3,41,0,0]}'><tr data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,40,0,0]}'><td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,40,1,0]}'><meta typeof=\"mw:Placeholder\" data-parsoid='{\"src\":\"[[{{{1}}}<nowiki>|</nowiki>{{{2}}}]]\",\"dsr\":[4,40,null,null]}'/></td></tr>\n</tbody></table>\n"); +add("html2html", "Abort table cell attribute parsing on wikilink", "<table data-parsoid='{\"dsr\":[0,94,2,2]}'>\n<tbody data-parsoid='{\"dsr\":[3,92,0,0]}'><tr data-parsoid='{\"autoInsertedEnd\":true,\"autoInsertedStart\":true,\"dsr\":[3,91,0,0]}'><td data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[3,50,1,0]}'> testing <a rel=\"mw:WikiLink\" href=\"./One\" title=\"One\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./One\"},\"sa\":{\"href\":\"one\"},\"dsr\":[13,24,6,2]}'>two</a><span typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[24,50,8,9]}'> | three </span></td><td data-parsoid='{\"stx_v\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[50,57,2,0]}'> four</td>\n<td data-parsoid='{\"a\":{\"testing\":null,\"one\":null,\"two\":null},\"sa\":{\"testing\":\"\",\"one\":\"\",\"two\":\"\"},\"autoInsertedEnd\":true,\"dsr\":[58,84,19,0]}'> three </td><td data-parsoid='{\"stx_v\":\"row\",\"autoInsertedEnd\":true,\"dsr\":[84,91,2,0]}'> four</td></tr>\n</tbody></table>\n"); add("html2html", "Template parameter as link source", "<p data-parsoid='{\"dsr\":[0,23,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main Page\"},\"dsr\":[0,23,17,2]}'>link</a></p>\n"); add("html2html", "Template as link source", "<p data-parsoid='{\"dsr\":[0,28,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main Page\"},\"dsr\":[0,28,17,2]}'>Main Page</a></p>\n\n<p data-parsoid='{\"dsr\":[30,58,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main Page\"},\"dsr\":[30,58,17,2]}'>Main Page</a></p>\n\n<p data-parsoid='{\"dsr\":[60,92,0,0]}'><a rel=\"mw:WikiLink\" href=\"./Wiki/Main_Page\" title=\"Wiki/Main Page\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Main_Page\"},\"sa\":{\"href\":\"wiki/Main Page\"},\"dsr\":[60,88,17,2]}'>Main Page</a>Page</p>\n"); add("html2html", "Template infinite loop", "<p data-parsoid='{\"dsr\":[0,89,0,0]}'><span class=\"error\" data-parsoid='{\"stx\":\"html\",\"dsr\":[0,89,20,7]}'>Template loop detected: <a rel=\"mw:WikiLink\" href=\"./Wiki/Template:Loop1\" title=\"Wiki/Template:Loop1\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"./Wiki/Template:Loop1\"},\"sa\":{\"href\":\"wiki/Template:Loop1\"},\"dsr\":[44,82,22,2]}'>Template:Loop1</a></span></p>\n"); @@ -975,7 +975,8 @@ add("html2wt", "Template with complex template as argument", "This is a test template with parameter (test)\n"); add("html2wt", "Template with thumb image (with link in description)", "{{paramtest|param = [[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}\n"); add("html2wt", "Template with complex arguments", "[[wiki/Template:Complextemplate|link]] This is a test template with parameter (test)\n"); -add("html2wt", "BUG 553: link with two variables in a piped link", "{|\n\n|<nowiki>[[{{{1}}}|{{{2}}}]]</nowiki>\n|}\n"); +add("html2wt", "BUG 553: link with two variables in a piped link", "{|\n|[[{{{1}}}<nowiki>|</nowiki>{{{2}}}]]\n|}\n"); +add("html2wt", "Abort table cell attribute parsing on wikilink", "{|\n| testing [[one|two]]<nowiki> | three </nowiki>|| four\n| testing one two | three || four\n|}\n"); add("html2wt", "Magic variable as template parameter", "This is a test template with parameter MediaWiki\n"); add("html2wt", "Template parameter as link source", "[[wiki/Main Page|link]]\n"); add("html2wt", "Template passing argument to another template", "including another template, This is a test template with parameter 'hmm'\n"); @@ -1399,7 +1400,6 @@ add("html2wt", "Non-empty attributes in th-cells", "{|\n\n! Foo \n! style=\"color: red\" | Bar\n|}\n"); add("html2wt", "Accept empty attributes in th-cells", "{|\n\n! foo \n! bar\n|}\n"); add("html2wt", "Empty table rows go away", "{|\n\n| Hello\n\n| there\n\n|}\n"); -add("html2wt", "RT-ed inter-element separators should be valid separators", "{|\n\n|}\n"); add("html2wt", "Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out", "{|\n|<small>foo\n\nbar\n|}\n\n{|\n|<small>foo<small>\n|}\n"); add("html2wt", "Empty TD followed by TD with tpl-generated attribute", "{|\n\n|\n\n|foo\n|}\n"); add("html2wt", "Indented table with an empty td", "{|\n\n|\n\n|foo\n|}\n"); @@ -1799,6 +1799,14 @@ add("selser", "BUG 553: link with two variables in a piped link [[3,1]]", "{|\n|[[{{{1}}}|{{{2}}}]]\n|}"); add("selser", "BUG 553: link with two variables in a piped link [2]", "riybxbthicfskyb9\n{|\n|[[{{{1}}}|{{{2}}}]]\n|}"); add("selser", "BUG 553: link with two variables in a piped link [[0,2]]", "{|\n<!--z79xd4wgjxphw7b9-->|[[{{{1}}}|{{{2}}}]]\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [1]", "{| data-foobar=\"w6muy2if0yrjm7vi\"\n| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[0,1]]", "{|\n| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[0,[[[2,0,0],1,0,2,[2]],4]]]", "{|\n|7s7418n1uo7uv7vi testing [[one|two]] | three || data-foobar=\"zomk9que1edygb9\" | four\n|2mhjtgea0fcg14i\n| testing one two | three ||5naus1mqi98gp66r four<!--hz9awkyqyfrbe29-->\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [2]", "xldg5ui1w96647vi\n{|\n| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[4,[2,3]]]", "{|<!--2pbfrmfop0mp9zfr--><!--rv6arn1q38cwhfr-->\n| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[3,1]]", "{|\n| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[0,2]]", "{|\n<!--l7obo7dbpflmcxr-->| testing [[one|two]] | three || four\n| testing one two | three || four\n|}"); +add("selser", "Abort table cell attribute parsing on wikilink [[4,[[2,[2],4,3,2],4]]]", "{|<!--w2ugfafj2x83erk9-->\n|18az3ae320dlsor\n| testing [[one|two]] | three ||icotw6yeh7x2yb9 four\n|w2ux7qtgctyb9\n|g1zrrcwd5kqn0zfr|| four<!--p8xffhgo254gqfr-->\n|}"); add("selser", "Template with targets containing wikilinks [4,0,1,2,1]", "p8pza9iyg3yaxlxr\n\n<nowiki>{{</nowiki>[[{{echo|foo}}]]}}\n\ndf60zk0z1v8ia4i\n\n{{{{echo|[[foo}}]]}}"); add("selser", "Template with targets containing wikilinks [[2,1,0],0,[0,0,2],0,0]", "h2hv5x8klgom9529<nowiki>{{</nowiki>[[foo]]}}\n\n<nowiki>{{</nowiki>[[{{echo|foo}}]]<nowiki/>ncfzvzzr3mzpvi<nowiki>}}</nowiki>\n\n{{{{echo|[[foo}}]]}}"); add("selser", "Template with targets containing wikilinks [0,3,2,0,2]", "{{[[foo]]}}\n\n8rx6djpk76ojq0k9\n\n{{[[{{echo|foo}}]]}}\n\n5oa9tnlujuivn29\n\n{{{{echo|[[foo}}]]}}"); @@ -2401,19 +2409,6 @@ add("selser", "Table with broken attribute value quoting on consecutive lines [[4,[[1,0,0],0]]]", "{|<!--nejaqckt9hmbcsor-->\n| title=\"Hello world\" data-foobar=\"bumvfdcvrbhme7b9\" |Foo\n| style=\"color:red|Bar\n|}"); add("selser", "Table with broken attribute value quoting on consecutive lines [[4,2]]", "{|<!--7wm4bxgh5f0w9udi--><!--xv1dekuqzsiw9udi-->\n| title=\"Hello world|Foo\n| style=\"color:red|Bar\n|}"); add("selser", "Table with broken attribute value quoting on consecutive lines [[0,[[2,0,3],3]]]", "{|\n|fk1rjyjbpej6ecdi\n| title=\"Hello world|Foo\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [3,1]", "{| data-foobar=\"x539yhci41xxbt9\"\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [1,1]", "[[foo]]\n{| data-foobar=\"0p92gdvzuuwhfr\"\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [0,[3,[2,4]]]", "{|<!--94t5edxysje2ke29-->\n|- [[foo]<!--ckb9ez0ylze3766r-->\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [4,[0,[0,3]]]", "jua9o47wi1gojemi\n{|\n|- [[foo]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [1,[0,[0,4]]]", "[[foo]]\n{|\n|- [[foo]<!--7u4ntcstjzto6r-->\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [[[2]],2]", "[[foo|662vco2tyo8q6w29foo]]\n\nyasgjcy1y1ll3di\n{|\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [1,2]", "[[foo]]\n\n80gcqjar6qrggb9\n{|\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [3,0]", "{|\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [0,[0,4]]", "{|\n<!--j8hwklray6ekx1or-->|}"); -add("selser", "RT-ed inter-element separators should be valid separators [0,1]", "{| data-foobar=\"io6h5rgsuyjh5mi\"\n|- [[foo]]\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [2,[0,[0,2]]]", "qyiayk5wxhn9izfr\n\n{|\n|- [[foo]<!--l16uj38p26eqm2t9--> \n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [2,[0,3]]", "a467voa6hewdygb9\n\n{|\n|}"); -add("selser", "RT-ed inter-element separators should be valid separators [4,1]", "m9sr4renr110pb9\n{| data-foobar=\"vqglzmqq4crcc8fr\"\n|- [[foo]]\n|}"); add("selser", "Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out [2,4,2]", "oxcq39cyuk07wrk9\n{|\n|<small>foo\nbar\n|}\nbtnbac04guj46lxr\n\ni10ii39io6hqto6r\n{|\n|<small>foo<small>\n|}"); add("selser", "Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out [[0,[[1],4]],3,[0,[[[[4,0]]],0]]]", "{|\n| data-foobar=\"6esm1j2nehup7gb9\" |<small>foo\nbar<!--t9z6766d6n06yldi-->\n|}\n{|\n|<small>4j0561nruz19vn29<small>\n|}"); add("selser", "Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out [2,0,3]", "zx1dph1o9tpam7vi\n{|\n|<small>foo\nbar\n|}\n"); diff --git a/tests/parserTests.txt b/tests/parserTests.txt index c8c63f3..1f38cc5 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -10348,12 +10348,40 @@ {| |[[{{{1}}}|{{{2}}}]] |} -!! html +!! html/php <table> <tr> <td>[[{{{1}}}|{{{2}}}]] </td></tr></table> +!! html/parsoid +<table> +<tbody><tr><td>[[<span about="#mwt5" typeof="mw:Param" data-parsoid='{"src":"{{{1}}}"}'>{{{1}}}</span>|<span about="#mwt2" typeof="mw:Param" data-parsoid='{"src":"{{{2}}}"}'>{{{2}}}</span>]]</td></tr> +!! end + +# See: T2553 +!! test +Abort table cell attribute parsing on wikilink +!! wikitext +{| +| testing [[one|two]] | three || four +| testing one two | three || four +|} +!! html/php +<table> +<tr> +<td> testing <a href="/index.php?title=One&action=edit&redlink=1" class="new" title="One (page does not exist)">two</a> | three </td> +<td> four +</td> +<td> three </td> +<td> four +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> testing <a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td> +<td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'> three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td></tr> +</tbody></table> !! end !! test @@ -23739,11 +23767,15 @@ {| |- [[foo]] |} -!! html +!! html/php <table> </table> +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr> +</tbody></table> !!end # Parsoid-only since PHP parser relies on Tidy for correct output -- To view, visit https://gerrit.wikimedia.org/r/237182 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0646442d27b863c6653491c43c319c3d87cf9ca5 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@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