jenkins-bot has submitted this change and it was merged. Change subject: T142617: Handle invalid titles in transclusions ......................................................................
T142617: Handle invalid titles in transclusions * It turns out that entities in template names of transclusions should NOT be url-decoded. Updated code to take care of this. * Added a new parser test to capture expectations about how entities are handled in transclusion titles. * Updated another test to make sure it is tested by the PHP parser as well. Change-Id: Iada3cb2d4d50d0e8b4fd739a07cac6d23a72fabc --- M lib/wt2html/tt/TemplateHandler.js M tests/parserTests.txt 2 files changed, 28 insertions(+), 2 deletions(-) Approvals: Arlolra: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/wt2html/tt/TemplateHandler.js b/lib/wt2html/tt/TemplateHandler.js index 7fe513e..b26cea1 100644 --- a/lib/wt2html/tt/TemplateHandler.js +++ b/lib/wt2html/tt/TemplateHandler.js @@ -439,7 +439,17 @@ // Resolve a possibly relative link and // normalize the target before template processing. - var title = env.makeTitleFromText(env.resolveTitle(target), undefined, true); + var title; + try { + title = env.resolveTitle(target); + } catch (e) { + // Invalid template target! + return null; + } + + // Entities in transclusions aren't decoded in the PHP parser + // So, treat the title as a url-decoded string! + title = env.makeTitleFromURLDecodedStr(title, undefined, true); if (!title) { // Invalid template target! return null; diff --git a/tests/parserTests.txt b/tests/parserTests.txt index fb65143..08d0da3 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -8001,6 +8001,20 @@ !! end !! test +Ensure that transclusion titles are not url-decoded +!! options +subpage title=[[Test]] +parsoid=wt2html +!! wikitext +{{Bar%C3%A9}} {{/Bar%C3%A9}} +!! html/php +<p>{{Bar%C3%A9}} {{/Bar%C3%A9}} +</p> +!! html/parsoid +<p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p> +!! end + +!! test Purely hash wikilink !! options title=[[User:test/123]] @@ -19388,9 +19402,11 @@ parsoid=wt2html !! wikitext {{../../../../More than parent}} -!! html +!! html/php <p>{{../../../../More than parent}} </p> +!! html/parsoid +<p>{{../../../../More than parent}}</p> !! end !! test -- To view, visit https://gerrit.wikimedia.org/r/307871 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iada3cb2d4d50d0e8b4fd739a07cac6d23a72fabc Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: C. Scott Ananian <canan...@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