jenkins-bot has submitted this change and it was merged. Change subject: Digest broken table and tr attributes ......................................................................
Digest broken table and tr attributes This avoids foster-parenting diffs like this: https://fr.wikipedia.org/w/index.php?title=Aquila_Italiana&diff=101605787&oldid=90404051 We should separately check why selser did not handle the foster-parented content correctly. Change-Id: Ia5a5bb6b4063438f65fed26e1acb8b844c147a01 --- M lib/pegTokenizer.pegjs.txt M tests/parserTests-blacklist.js M tests/parserTests.txt 3 files changed, 49 insertions(+), 36 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt index b6e05e8..56f2b74 100644 --- a/lib/pegTokenizer.pegjs.txt +++ b/lib/pegTokenizer.pegjs.txt @@ -2029,16 +2029,13 @@ / table_caption_tag / table_end_tag) + table_start_tag = b:"{" p:pipe - ta:(ga:generic_attribute - // ok to normalize away stray |} on rt (see bug 57360) - (space* table_end_tag)? {return ga;} - )* // ok to normalize away stray |} on rt (see bug 57360) - space* table_end_tag? - space* - tsEndPos:({return pos;}) + & { return stops.push('table', false); } + ta:(generic_attribute)* + tsEndPos:({stops.pop('table'); return pos;}) { var tblStart = new TagTk( 'table', [], { tsr: [pos0, tsEndPos] } ); if (p !== "|") { @@ -2067,8 +2064,9 @@ table_row_tag = //& { console.warn("table row enter @" + input.substr(pos, 30)); return true; } p:pipe dashes:"-"+ + & { return stops.push('table', false); } a:(generic_attribute)* - tagEndPos:({return pos;}) + tagEndPos:({stops.pop('table'); return pos;}) // handle tables with missing table cells after a row td:implicit_table_data_tag? { diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js index 0366f27..12d16c9 100644 --- a/tests/parserTests-blacklist.js +++ b/tests/parserTests-blacklist.js @@ -621,7 +621,7 @@ add("wt2wt", "Sanitizer: Closing of closed but not open table tags", "Table not started"); add("wt2wt", "Sanitizer: Validating the contents of the id attribute (bug 4515)", "<br id=\"9\" />\n"); add("wt2wt", "Sanitizer: Validating that <meta> and <link> work, but only for Microdata", "<div itemscope=\"\">\n\t<nowiki><meta itemprop=\"hello\" content=\"world\">\n\t<meta http-equiv=\"refresh\" content=\"5\">\n\t<meta itemprop=\"hello\" http-equiv=\"refresh\" content=\"5\">\n\t<link itemprop=\"hello\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\" href=\"{{SERVER}}\">\n\t<link rel=\"stylesheet\" itemprop=\"hello\" href=\"{{SERVER}}\"></nowiki>\n</div>"); -add("wt2wt", "Fuzz testing: Parser13", "{|\n| http://a |\n|}"); +add("wt2wt", "Fuzz testing: Parser13", "{| \n| http://a |\n|}"); add("wt2wt", "Fuzz testing: Parser14-table", "==a==\n{| style=\"__TOC__\"\n|}"); add("wt2wt", "Fuzz testing: Parser16", "{|\n!https://||||||\n|}"); add("wt2wt", "Fuzz testing: Parser21", "{|\n! irc://{{ftp://a\" onmouseover=\"alert('hello world');\"\n|\n|}"); @@ -661,7 +661,7 @@ add("wt2wt", "RT-ed inter-element separators should be valid separators", "[[foo]]\n{|\n|- \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"); -add("wt2wt", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost)", "<nowiki> || ||</nowiki>\n{|\n|-\n| a\n|}"); +add("wt2wt", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost)", "<nowiki> || ||</nowiki>\n<table>\n<tr><td> a\n</table>"); add("wt2wt", "Table in fosterable position", "{{OpenTable}}\n<div>\n{|\n|}\n"); add("wt2wt", "Images: upright option is ignored on inline and frame images (parsoid)", "[[File:Foobar.jpg|500x500px|caption]]\n"); @@ -3114,17 +3114,17 @@ add("selser", "bug 5918: autonumbering [2,2,2,0,1,0,4,3,3]", "q4161ffjoghz1tt9\n\n[http://first/] [http://second] [ftp://ftp]9mqjhs3qk334ygb9\noj5hiqw208fzjjor\nftp://inlineftp\n\n[mailto:enclo...@mail.tld With target]\n\nuo7m0iyc06pc766r"); add("selser", "bug 5918: autonumbering [[0,0,0,2,2],2,2,2,[4],4,3,2,1]", "[http://first/] [http://second]63dnfi29qiod2t9 t8r39k7lcccpiudi[ftp://ftp]8g8p7zhtu8lg14i\n8mfu9873s5vu0udi\n\nftp://inlineftp9vrfzii70zveu3di\n\nff69h9jntxuvj9k911nlng0404927qfrl3bh3pww1mr3haor\n\nmailto:inl...@mail.tld\n"); add("selser", "Fuzz testing: Parser13 [2]", "whfwe630sy8pvi\n{| \n| http://a|"); -add("selser", "Fuzz testing: Parser13 [[0,[[1]]]]", "{|\n| data-foobar=\"bz304nhr12359udi\" http://a ||}"); -add("selser", "Fuzz testing: Parser13 [1]", "{| data-foobar=\"k83lm0w7lheyiudi\"\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,2]]", "{|<!--ot0k5hk2dibe29-->\n<!--ddndi7e9wtlkrzfr-->| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[0,[[1]]]]", "{| \n| data-foobar=\"bz304nhr12359udi\" http://a ||}"); +add("selser", "Fuzz testing: Parser13 [1]", "{| data-foobar=\"k83lm0w7lheyiudi\" \n| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[2,2]]", "{|<!--ot0k5hk2dibe29--> \n<!--ddndi7e9wtlkrzfr-->| http://a||}"); add("selser", "Fuzz testing: Parser13 [[4,2]]", "{|<!--5r0vu1d4d02akyb9--><!--kgfqc1jnmjyh9f6r-->\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,1]]", "{|\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,2]]", "{|\n<!--aox6m05qx79icnmi-->| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[0,[1]]]", "{|\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,[[1]]]]", "{|<!--k7dytmk4x4fpf1or-->\n| data-foobar=\"6eljtbwlg39dx6r\" http://a ||}"); +add("selser", "Fuzz testing: Parser13 [[0,1]]", "{| \n| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[0,2]]", "{| \n<!--aox6m05qx79icnmi-->| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[0,[1]]]", "{| \n| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[2,[[1]]]]", "{|<!--k7dytmk4x4fpf1or--> \n| data-foobar=\"6eljtbwlg39dx6r\" http://a ||}"); add("selser", "Fuzz testing: Parser13 [[4,[1]]]", "{|<!--bc5lt7d97qcwhfr-->\n| http://a ||}"); add("selser", "Fuzz testing: Parser13 [[4,0]]", "{|<!--bdcj5y141zcl3di-->\n| http://a||}"); -add("selser", "Fuzz testing: Parser13 [[2,0]]", "{|<!--fk6xcjz25vc84cxr-->\n| http://a||}"); +add("selser", "Fuzz testing: Parser13 [[2,0]]", "{|<!--fk6xcjz25vc84cxr--> \n| http://a||}"); add("selser", "Fuzz testing: Parser14-table [1,0,0]", "==a==\n{| STYLE=__TOC__"); add("selser", "Fuzz testing: Parser14-table [4,4,0]", "u98ofogyawwb3xrtty3c40hu0gujtt9\n{| STYLE=__TOC__"); add("selser", "Fuzz testing: Parser14-table [0,2,0]", "==a==\nu14a8f95rx8q6w29\n{| STYLE=__TOC__"); @@ -3545,20 +3545,20 @@ add("selser", "Improperly nested inline or quotes tags with whitespace in between [[3,4,4,0,2]]", "zspuuqxabmtmlsorhu9yn80lmnm6lxr''' ''x'''f278nrkbehwu3di ''"); add("selser", "Improperly nested inline or quotes tags with whitespace in between [[[0,3],[3],0,3,0]]", "<span> </span></s>\n ''"); add("selser", "Improperly nested inline or quotes tags with whitespace in between [[[2,1],[3],3,[0,3],0]]", "<span>i9p8te7ufdmquxr <s data-foobar=\"xoximjgruc95dn29\">x</span></s>''' ''' ''"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) 5", "\n{|\n|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,3]]", "\n{|\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,3,[3,[3,0]]]", "\n{|\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [[4],2,[0,2]]", "1cqp1we3vbyv6lxraa9lqxou81if6r\n{|\n<!--ikdnmfgo6wimgqfr-->|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,[4,4]]]", "\n{|\n<!--eppdx87on0dd9529--><!--rsvnvzp8z32nvcxr-->|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [[2],2,2]", "15phixjatjn0cnmi || ||ncg67wf6jpaxlxr\nlseqic7t5okr19k9\n{|\n|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,2]]", "\n{|\n<!--619ferqsrkmiy66r-->|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [2,2,[0,[0,4]]]", "zayftnru704wjyvigy9c4jt9nejt6gvi\n{|\n|- || ||\n| a<!--og9puq3hpok49529-->\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [2,0,[4,[1,0]]]", "v4428ruthukxogvi\n{|<!--hzr601xnttricnmi-->\n|- data-foobar=\"942nki4ty9gxecdi\"\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,1]]", "\n{|\n|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [4,0,2]", "k40mf30abvwe9udi\nwyf7ovw7gd7h9f6r\n{|\n|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [1,0,[3,0]]", "<nowiki> || ||</nowiki>\n{|\n|- || ||\n| a\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[3,[[4],3]]]", "\n{|\n|-\n|5idqtjfqctgiizfr\n|}"); -add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,2]", "\n3ufvfgjc3tinewmi\n{|\n|- || ||\n| a\n|}"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) 5", "\n<table>\n<tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,3]]", "\n<table></table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,3,[3,[3,0]]]", "<table>\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [[4],2,[0,2]]", "1cqp1we3vbyv6lxraa9lqxou81if6r\n<table>\n<!--ikdnmfgo6wimgqfr--><tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,[4,4]]]", "\n<table>\n<!--eppdx87on0dd9529--><!--rsvnvzp8z32nvcxr--></table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [[2],2,2]", "15phixjatjn0cnmi || ||ncg67wf6jpaxlxr\nlseqic7t5okr19k9<table>\n<tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,2]]", "\n<table>\n<!--619ferqsrkmiy66r--><tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [2,2,[0,[0,4]]]", "zayftnru704wjyvigy9c4jt9nejt6gvi\n<table>\n<tr> || ||\n<td> a<!--og9puq3hpok49529--></table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [2,0,[4,[1,0]]]", "v4428ruthukxogvi\n<table><!--hzr601xnttricnmi--><tr data-foobar=\"942nki4ty9gxecdi\"><td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[0,1]]", "\n<table>\n<tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [4,0,2]", "k40mf30abvwe9udi\nwyf7ovw7gd7h9f6r<table>\n<tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [1,0,[3,0]]", "<nowiki> || ||</nowiki>\n<table><tr> || ||\n<td> a\n</table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,[3,[[4],3]]]", "\n<table><tr><td>5idqtjfqctgiizfr</td></table>"); +add("selser", "2. Ensure fostered text content is wrapped in spans (traps regressions around fostered marker on the span getting lost) [0,0,2]", "\n3ufvfgjc3tinewmi<table>\n<tr> || ||\n<td> a\n</table>"); add("selser", "Table in fosterable position 5", "{{OpenTable}}\n<div>\n{|\n|}\n"); add("selser", "Image: Block level image should have \\n before and after [2,4,0,2,0]", "pgawtyr28podpldi\n\n123d7ykse27vjyh9f6r[[File:Foobar.jpg|right|thumb|150x150px]]vfwkah17bjbmaemi\n456"); add("selser", "Images: upright option is ignored on inline and frame images (parsoid) [1]", "[[File:Foobar.jpg|500x500px|upright=0.5|caption]]"); diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 0e83380..fdefd8a 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -18600,6 +18600,21 @@ </tbody></table> !! end +!! test +Tables: Digest broken attributes on table and tr tag +!! options +parsoid=wt2html +!! input +{| || |} ++ +|- || || ++ -- +|} +!! result +<table> +<tbody> +<tr></tr> +</tbody></table> +!! end + #### --------------- Links ---------------- #### 1. Quote marks in link text #### 2. Wikilinks: Escapes needed @@ -19339,10 +19354,10 @@ !!options parsoid=wt2html,wt2wt !!input -{| -|- || || -| a -|} +<table> +<tr> || || +<td> a +</table> !!result <span> || ||</span> <table> -- To view, visit https://gerrit.wikimedia.org/r/115856 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia5a5bb6b4063438f65fed26e1acb8b844c147a01 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: GWicke <gwi...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: GWicke <gwi...@wikimedia.org> Gerrit-Reviewer: Marcoil <marc...@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