Bugzilla – Attachment 162871 Details for
Bug 36244
Template toolkit syntax not escaped in letter templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36244: Unit test for tt syntax in parameters
Bug-36244-Unit-test-for-tt-syntax-in-parameters.patch (text/plain), 2.60 KB, created by
Jonathan Druart
on 2024-03-07 09:44:35 UTC
(
hide
)
Description:
Bug 36244: Unit test for tt syntax in parameters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-03-07 09:44:35 UTC
Size:
2.60 KB
patch
obsolete
>From 34c7148024f0729672eeb3bc9099896e778e6ed0 Mon Sep 17 00:00:00 2001 >From: Andreas Jonsson <andreas.jonsson@kreablo.se> >Date: Thu, 7 Mar 2024 09:07:49 +0000 >Subject: [PATCH] Bug 36244: Unit test for tt syntax in parameters > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Letters.t | 47 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 46 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index ade28f89ad5..8295c63baa5 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 99; >+use Test::More tests => 100; > use Test::MockModule; > use Test::Warn; > use Test::Exception; >@@ -1410,3 +1410,48 @@ subtest 'Test message_id parameter for SendQueuedMessages' => sub { > is( $message_1->{status}, 'failed', 'Message 1 status is unchanged' ); > is( $message_2->{status}, 'sent', 'Valid from_address => status sent' ); > }; >+ >+subtest 'Template toolkit syntax in parameters' => sub { >+ >+ my $borrowernumber = Koha::Patron->new( >+ { >+ firstname => 'Robert', >+ surname => '[% USE Categories %][% Categories.all().search_related("borrowers").count() %]', >+ categorycode => $patron_category, >+ branchcode => $library->{branchcode}, >+ dateofbirth => $date, >+ smsalertnumber => undef, >+ } >+ )->store->borrowernumber; >+ >+ my $title = q|<<branches.branchname>> - <<status>>|; >+ my $content = q{Dear <<borrowers.firstname>> <<borrowers.surname>>}; >+ >+ $dbh->do( >+ q|INSERT INTO letter(branchcode,module,code,name,is_html,title,content,message_transport_type) VALUES (?,'my module','tt test','my name',1,?,?,'email')|, >+ undef, $library->{branchcode}, $title, $content >+ ); >+ >+ my $tables = { >+ borrowers => $borrowernumber, >+ branches => $library->{branchcode}, >+ biblio => $biblionumber, >+ }; >+ my $substitute = { >+ status => 'overdue', >+ }; >+ my $prepared_letter = GetPreparedLetter( >+ module => 'my module', >+ branchcode => $library->{branchcode}, >+ letter_code => 'tt test', >+ tables => $tables, >+ substitute => $substitute, >+ repeat => [], >+ ); >+ >+ is( >+ $prepared_letter->{content}, >+ 'Dear Robert [% USE Categories %][% Categories.all().search_related("borrowers").count() %]', >+ 'Template toolkit syntax in parameter was not evaluated.' >+ ); >+}; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36244
:
162866
|
162867
|
162868
|
162871
|
162872
|
162876
|
162877
|
162908
|
162909
|
162910
|
163255
|
163256
|
163257
|
163383
|
163384
|
163385