Bug 31165: Scrub "Public note" field for Course Reserves

When displaying the "Public note" for Course Reserves, we scrub the HTML
using the "note" scrubber type.

Test plan:
0. Apply the patch
1. Go to http://localhost:8081/cgi-bin/koha/course_reserves/course-reserves.pl
2. Click "New course"
3. Fill in required fields
4. In staff note and public note add the following:
<script>alert('boo!')</script><p>Hello!</p>
5. Click Save

6. Click "Add reserves"
7. Add "39999000001310" to Item barcode
8. Click "Submit"
9. Fill in all required fields
10. Add the following for Staff note and Public note:
<script>alert('boo2!')</script><p>Item!</p>
11. Click "Save"

12. Go back to your course reserve
13. Note the HTML is scrubbed on "Public note"
14. Go to http://localhost:8081/cgi-bin/koha/course_reserves/course-reserves.pl
15. Note the HTML is scrubbed on "Public note"

16. Go to http://localhost:8080/cgi-bin/koha/opac-course-reserves.pl
17. Note the HTML is scrubbed on "Notes"
18. Click on your course reserves
19. Note the HTML is scrubbed on "Notes"

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Cook 2024-11-20 01:09:00 +00:00 committed by Katrin Fischer
parent 58bd633d8e
commit c24969a208
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 11 additions and 7 deletions

View File

@ -6,6 +6,7 @@
[% USE ItemTypes %]
[% USE Branches %]
[% USE TablesSettings %]
[% USE HtmlScrubber %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
@ -126,7 +127,7 @@
</li>
[% END %]
[% IF ( course.public_note ) %]
<li><span class="label">Public note: </span> [% course.public_note | $raw %]</li>
<li><span class="label">Public note: </span> [% course.public_note | scrub_html type => 'note' | $raw %]</li>
[% END %]
<li><span class="label">Student count: </span> [% course.students_count || "0" | html %]</li>
<li><span class="label">Status: </span> [% IF course.enabled == 'yes' %]Active[% ELSE %]Inactive[% END %]</li>
@ -297,9 +298,9 @@
</td>
<td
>[% IF (cr.public_note) %]
[% cr.public_note | $raw %]
[% cr.public_note | scrub_html type => 'note' | $raw %]
[% ELSIF (cr.item.itemnotes) %]
[% cr.item.itemnotes | $raw %]
[% cr.item.itemnotes | scrub_html type => 'note' | $raw %]
[% END %]
</td>

View File

@ -3,6 +3,7 @@
[% USE Asset %]
[% USE AuthorisedValues %]
[% USE TablesSettings %]
[% USE HtmlScrubber %]
[% PROCESS 'i18n.inc' %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
@ -74,7 +75,7 @@
[% END %]
</td>
<td>[% c.staff_note | html %]</td>
<td>[% c.public_note | $raw %]</td>
<td>[% c.public_note | scrub_html type => 'note' | $raw %]</td>
<td>[% c.students_count | html %]</td>
<td>
[% IF c.enabled == 'yes' %]

View File

@ -6,6 +6,7 @@
[% USE ItemTypes %]
[% USE Branches %]
[% USE TablesSettings %]
[% USE HtmlScrubber %]
[% PROCESS 'i18n.inc' %]
[% PROCESS 'html_helpers.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
@ -54,7 +55,7 @@
</ul>
</li>
[% END %]
[% IF ( course.public_note ) %]<li><span class="label">Notes:</span> [% course.public_note | $raw %]</li>[% END %]
[% IF ( course.public_note ) %]<li><span class="label">Notes:</span> [% course.public_note | scrub_html type => 'note' | $raw %]</li>[% END %]
</ol>
</div>
@ -99,7 +100,7 @@
<td data-order="[% cr.issue.date_due | html %]">[% cr.issue.date_due | $KohaDates as_due_date => 1 %]</td>
<td
>[% IF ( cr.public_note ) %]
[% cr.public_note | $raw %]
[% cr.public_note | scrub_html type => 'note' | $raw %]
[% ELSIF ( cr.item.itemnotes ) %]
[% cr.item.itemnotes | $raw %]
[% END %]

View File

@ -6,6 +6,7 @@
[% PROCESS 'i18n.inc' %]
[% PROCESS 'html_helpers.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
[% USE HtmlScrubber %]
<title
>[% FILTER collapse %]
[% t("Course reserves") | html %]
@ -63,7 +64,7 @@
>
[% END %]
</td>
<td>[% c.public_note | $raw %]</td>
<td>[% c.public_note | scrub_html type => 'note' | $raw %]</td>
<td></td>
</tr>
[% END %]