Bug 30330 - Bad fields within comments in a HTML notice still cause a crash
Summary: Bad fields within comments in a HTML notice still cause a crash
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-22 12:31 UTC by Marcel de Rooy
Modified: 2024-07-04 20:37 UTC (History)
0 users

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2022-03-22 12:31:54 UTC
I had something like this in a notice:

<!-- [% table.unkown_field %] -->

The table is linked to a valid Koha object. The field is wrong.
Running Print slip from within circ/article-requests caused a crash like:

ERROR PROCESSING TEMPLATE: undef error - The method Koha::<<TABLE>>-><<UNKNOWN_FIELD>> is not covered by tests!

While this is within a comment, I did not hope to see that.
Comment 1 Marcel de Rooy 2022-03-22 12:32:37 UTC
(In reply to Marcel de Rooy from comment #0)
> Running Print slip from within circ/article-requests caused a crash like:

Yes it was article_requests.toc_request :)
Comment 2 Marcel de Rooy 2022-03-22 12:33:36 UTC
(In reply to Marcel de Rooy from comment #1)
> (In reply to Marcel de Rooy from comment #0)
> > Running Print slip from within circ/article-requests caused a crash like:
> 
> Yes it was article_requests.toc_request :)

And not present in that database. But it just serves as an example that fields within comments are evaluated.
Comment 3 Marcel de Rooy 2022-03-22 13:48:40 UTC
As a side note (lowering the severity a bit): 

You could also try [%# bad stuff %],
this works at least partially as long as the bad stuff does not contain %] which would end the comment.

And for fun, as a crazy workaround, you could replace an ending %] by %][%# resulting in for instance:

[%# <p>TOC: [% IF article_request.toc_request %][%#<strong>Include TOC</strong>[% ELSE %][%#No[% END %]

It works, but serves as a 'good' example of a bad workaround.

Should we call this a Template Toolkit bug or what?
Comment 4 Katrin Fischer 2023-06-17 19:03:33 UTC
I think if you use HTML comments, it will still get parsed by TT and that is intentional. It allows you to put things into the templates that are only visible in source, like maybe our TEMPLATE FILE comment in the OPAC. You would have to use a TT comment if you didn't want it to show up in the code/being parsed at all.

I believe this is not a bug, but working as intended.