[Bug 44151] New: xt/tt_tidy.t does not catch templates with commented-out head and body tags
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 Bug ID: 44151 Summary: xt/tt_tidy.t does not catch templates with commented-out head and body tags Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org Target Milestone: --- The Koha Template Toolkit prettier plugin rewrites </head>, <body ...> and </body> as HTML comments while it formats a template (they are unbalanced inside a single TT file), and misc/devel/tidy.pl reverts that. A template formatted with prettier directly (npx prettier, yarn prettier --write, editor format-on-save) keeps the comments, so the page is served without a head or body tag. xt/tt_tidy.t does not catch this. It compares the file with the output of 'tidy.pl --no-write'. Prettier turns an existing <!--</head>--> into <!--<!--</head>-->-->, tidy.pl reverts only the inner pair, so the output equals the damaged file and the test passes. Running tidy.pl on a damaged file does not repair it either. The damage has reached the tree. admin/searchengine/elasticsearch/mappings.tt has had '<!--</head>-->' and '<!--<body id="admin_searchengine_mappings" class="admin">-->' since bug 22639, and the notices, print_notice and register templates were damaged the same way while fixing the failing Jenkins tests. Test plan: 1. In a template, replace '</head>' with '<!--</head>-->' and '<body ...>' with '<!--<body ...>-->' 2. Run: prove xt/tt_tidy.t => Before the patch: passes, although the template is broken 3. Run: perl misc/devel/tidy.pl path/to/template.tt => Before the patch: the comments are still there => After the patch: </head> and <body ...> are restored 4. Run: prove xt/find-commented-head-body.t => After the patch: fails with the file name and line numbers while the comments are present, and passes once tidy.pl has restored the tags 5. Run: prove xt/tt_tidy.t => After the patch: fails for the damaged template until it is tidied -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 211995 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211995&action=edit Bug 44151: Make tidy.pl repair and xt catch commented-out head and body tags The Template Toolkit prettier plugin rewrites </head>, <body ...> and </body> as HTML comments because they are unbalanced inside a single template, and misc/devel/tidy.pl reverts that. A template formatted with prettier directly keeps the comments, so its page is served without a head or body tag. xt/tt_tidy.t did not catch this. Prettier nests an existing <!--</head>--> into <!--<!--</head>-->-->, tidy.pl reverted only the inner pair, so its output equalled the damaged file and the test passed. tidy.pl could not repair a damaged file either. * tidy.pl: revert the plugin substitutions, nested ones included, before prettier runs as well as after, so a damaged file is repaired. xt/tt_tidy.t now fails for a damaged template. * xt/find-commented-head-body.t: new test that fails with the file name and line numbers for a commented-out <head>, <body> or </body>, and says to use tidy.pl. To test: 1. In a template, replace '</head>' with '<!--</head>-->' and '<body ...>' with '<!--<body ...>-->' 2. prove xt/tt_tidy.t => Before the patch: passes, although the template is broken => After the patch: fails for that template 3. perl misc/devel/tidy.pl path/to/template.tt => Before the patch: the comments are still there => After the patch: </head> and <body ...> are restored 4. prove xt/find-commented-head-body.t => Fails with the file name and line numbers while the comments are present, passes once tidy.pl has restored the tags 5. Revert the template and run prove xt/tt_tidy.t xt/find-commented-head-body.t => both pass -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #211995|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 212026 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212026&action=edit Bug 44151: Make tidy.pl repair and xt catch commented-out head and body tags The Template Toolkit prettier plugin rewrites </head>, <body ...> and </body> as HTML comments because they are unbalanced inside a single template, and misc/devel/tidy.pl reverts that. A template formatted with prettier directly keeps the comments, so its page is served without a head or body tag. xt/tt_tidy.t did not catch this. Prettier nests an existing <!--</head>--> into <!--<!--</head>-->-->, tidy.pl reverted only the inner pair, so its output equalled the damaged file and the test passed. tidy.pl could not repair a damaged file either. * tidy.pl: revert the plugin substitutions, nested ones included, before prettier runs as well as after, so a damaged file is repaired. xt/tt_tidy.t now fails for a damaged template. * xt/find-commented-head-body.t: new test that fails with the file name and line numbers for a commented-out <head>, <body> or </body>, and says to use tidy.pl. To test: 1. In a template, replace '</head>' with '<!--</head>-->' and '<body ...>' with '<!--<body ...>-->' 2. prove xt/tt_tidy.t => Before the patch: passes, although the template is broken => After the patch: fails for that template 3. perl misc/devel/tidy.pl path/to/template.tt => Before the patch: the comments are still there => After the patch: </head> and <body ...> are restored 4. prove xt/find-commented-head-body.t => Fails with the file name and line numbers while the comments are present, passes once tidy.pl has restored the tags 5. Revert the template and run prove xt/tt_tidy.t xt/find-commented-head-body.t => both pass Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44151 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |arthur.suzuki@biblibre.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org