https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33350

Adolfo Rodríguez Taboada <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #148796|0                           |1
        is obsolete|                            |

--- Comment #3 from Adolfo Rodríguez Taboada <[email protected]> ---
Created attachment 201637
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201637&action=edit
Fix greedy regex in repeat_enclosing_tags — non-greedy while loop processes
each block independently. Includes unit test.

The root cause is a greedy .* in GetPreparedLetter's repeat_enclosing_tags
block (C4/Letters.pm). When a template has multiple <item> blocks (e.g.
bilingual ODUE with one block per language), the greedy match consumes from the
first <item> to the last </item>, merging all blocks and swallowing the text
between them.

Fix: non-greedy .*? in a while loop — each block matched and expanded
independently.

Tested manually in a local instance against a customized ODUE email template
with the pattern English + Spanish <item> blocks.

Re Lucas's comment: yes, TT's [% FOREACH item IN items %]...[% END %] can do
this, but it uses a different code path in GetPreparedLetter (the loops
parameter, not repeat). The <item>...</item> syntax is the legacy/historical
notice format and both coexist. Many production templates rely on this syntax.
Migrating them all to TT would be a separate, potentially breaking effort.

Re the unit test request: included. New subtest in t/db_dependent/Letters.t —
"Bug 33350 - repeat_enclosing_tags expands each block independently" — creates
a template with two <item> blocks, calls GetPreparedLetter with two
pre-resolved item hashrefs, and asserts each block is expanded independently
with all items.

Greetings, Adolfo.

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to