jenkins-bot has submitted this change and it was merged. Change subject: Bug fix in heading escaping ......................................................................
Bug fix in heading escaping * Only run when opts.isLastChild of the heading. Bug: T84903 Change-Id: I46d7dad9a6f97fbae9389e2b4530de46f80d6392 --- M lib/wts.escapeWikitext.js M tests/parserTests-blacklist.js M tests/parserTests.txt 3 files changed, 6 insertions(+), 15 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/wts.escapeWikitext.js b/lib/wts.escapeWikitext.js index 5f7618c..59ad35c 100644 --- a/lib/wts.escapeWikitext.js +++ b/lib/wts.escapeWikitext.js @@ -34,7 +34,9 @@ } // Only "=" at the extremities trigger escaping - if (opts.isLastChild && DU.isText(DU.firstNonDeletedChildNode(headingNode))) { + if ( opts.node.parentNode === headingNode && opts.isLastChild && + DU.isText(DU.firstNonDeletedChildNode(headingNode)) + ) { var line = state.currLine.text; if (line.length === 0) { line = text; diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js index 62d3461..6ae203f 100644 --- a/tests/parserTests-blacklist.js +++ b/tests/parserTests-blacklist.js @@ -525,7 +525,6 @@ add("wt2wt", "Ref: 10. Unclosed HTML tags should not leak out of ref-body", "A <ref><b> foo </ref> B C\n\n<references />"); add("wt2wt", "References: 5. ref tags in references should be processed while ignoring all other content", "A <ref name=\"a\" />\nB <ref name=\"b\">bar</ref>\n\n<references>\n<ref name=\"a\">foo</ref>\n</references>"); add("wt2wt", "Entities in ref name", "<ref name=\"test &amp; me\">hi</ref>\n"); -add("wt2wt", "Headings: 4a'. No escaping needed (Parsoid bug T84903)", "= ''<nowiki>=</nowiki>''foo= =\n"); add("wt2wt", "HTML tag with broken attribute value quoting", "<span title=\"Hello world\">Foo</span>\n"); add("wt2wt", "Parsoid-only: 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|}"); @@ -2785,8 +2784,6 @@ add("selser", "References: 5. ref tags in references should be processed while ignoring all other content [0,2,0]", "A <ref name=\"a\" />\nB <ref name=\"b\">bar</ref>\n\nky16pugtafywrk9\n\n<references>\n<ref name=\"a\">foo</ref>\nThis should just get lost.\n</references>"); add("selser", "Entities in ref name [2]", "72oie2a08o69wwmi\n\n<ref name=\"test & me\">hi</ref>"); add("selser", "Entities in ref name [1]", "<ref name=\"test & me\">hi</ref>"); -add("selser", "Headings: 4a'. No escaping needed (Parsoid bug T84903) [2]", "qj77lglp8h5jnhfr\n= ''=''foo= ="); -add("selser", "Headings: 4a'. No escaping needed (Parsoid bug T84903) [1]", "= ''=''foo= ="); add("selser", "Headings: 5. Empty headings [[2],3,2,0,4,4,0,2,1,3,0]", "=hnjo2713bjvjwcdi<nowiki/>=\nx2d05yq3dapaxlxr\n==<nowiki/>==\n\nkaovt9si227ta9k9\n\nb2688fvzpaocrf6r\n====<nowiki/>====\nljshl952j0emte29\n\n=====<nowiki/>=====\n\n======<nowiki/>======"); add("selser", "Headings: 6a. Heading chars in SOL context (with trailing spaces) [4,0,1,0,4,4,[2],3]", "o4fu7yz6zedvlsor\n\n<nowiki>=a=</nowiki> \n\nfzi337zwgfmbzkt9\n\nrziif3qr3rspp66r\n\nzm9kz709iqpsnhfr<nowiki>=a=</nowiki> \t"); add("selser", "1a. Quotes inside <b> and <i> [[[0,2,0],3,0,0,2,0,1,2,0,[4,2,2],0,1,3,0,2,[4,4,[2,0],0],3,[3],0,0,1,3,2,4,0,[2,0],1,0,3,4,2,0,3,0,0,0,0,2,0,0,0,2,4,0,0,4]]", "''<nowiki/>bt5073jrxz2gldi'foo'<nowiki/><nowiki>''foo''</nowiki>''\n6563iftvc71wz5mi''<nowiki>'''foo'''</nowiki>''\n''foo''yv6gd1r11qbyb9<nowiki/>'s\n'''ge4wqkqzeoqg2e29ycci4uro5wx6flxr'foo'onh4xihxdek4kj4i<nowiki/>'''\n'''<nowiki>''foo''</nowiki><nowiki>'''foo'''</nowiki>'''f1gwwblkysii19k9\n'''em5maqbfah71ra4izwselowkgxu07ldi''fmyr1ptercf2yb9bar'<nowiki/>''baz'''<nowiki/>'s\n'''foo''s1x6z3q0pwfgk3xr''foo''eo98hc80ue7mn29'\n''luf993p203a6ecdifoo'<nowiki/>''<nowiki/>'\n'9ixyk03e6k73nmib3uz6pdpbziod2t9<nowiki/>'\n'\n'''foo'''<nowiki/>'\n'n8h003eevc1pp66r<nowiki/>'''foo'''<nowiki/>'\nqzypu69mxf450zfr''fools'<span> errand</span>''f9fa9v2yqf7s0pb9''<span>fool</span>'s errand''\na|!*#-:;+-~[]{}b'eeuga531ydivbo6r\n"); diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 964203b..4c15c58 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -20053,6 +20053,8 @@ == foo= == = = = + += ''=''foo= = !! html/parsoid <h1>=foo</h1> <h1>foo=</h1> @@ -20061,18 +20063,8 @@ <h2>=foo</h2> <h2>foo=</h2> <h1>=</h1> -!!end - -!! test -Headings: 4a'. No escaping needed (Parsoid bug T84903) -!! wikitext -= ''=''foo= = -!! html/php -<h1><span class="mw-headline" id=".3Dfoo.3D"><i>=</i>foo=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: =foo=">edit</a><span class="mw-editsection-bracket">]</span></span></h1> - -!! html/parsoid <h1><i>=</i>foo=</h1> -!! end +!!end !! test Headings: 4b. No escaping needed (inside p-tags) -- To view, visit https://gerrit.wikimedia.org/r/181270 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I46d7dad9a6f97fbae9389e2b4530de46f80d6392 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@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