Commit Graph

58537 Commits

Author SHA1 Message Date
Jonathan Druart 319d6f88cd
Bug 40444: Add a test to ensure all Perl test files use Test::NoWarnings
This patch adds a new xt test (xt/use-test-no-warnings.t) to make sure
all our Perl test files will use Test::NoWarnings.

It also adds Test::NoWarnings to some files that were missing it and
that didn't need any other changes.

However we still have 7 non-trivial tests that we will consider
exception for now, until they are fixed.

Test plan:
  prove xt/use-test-no-warnings.t
should return green.
And all other tests modified by this patch (the qa script will do that
for you)

You can also test the 2 selenium tests:
1. DROP and CREATE the DB
  DROP DATABASE koha_kohadev;
  CREATE DATABASE koha_kohadev;
  restart_all
2. KOHA_TESTING=1 prove t/db_dependent/selenium/00-onboarding.t
3. Repeat 1
2. KOHA_TESTING=1 prove t/db_dependent/selenium/01-installation.t

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 63eb2e1f4a)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:25 +02:00
Paul Derscheid a52239172b
Bug 40305: DBRev 25.05.03.005
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:25 +02:00
Martin Renvoize 4e596b8fff
Bug 40305: Add database update to fix existing notice templates
This database update fixes existing RECEIPT and ACCOUNT_CREDIT notice
templates that may still use the old 'collected' variable instead of
'tendered'. It handles various formatting patterns and provides
verification that the conversion was successful.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4b300b1c1d)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:24 +02:00
Martin Renvoize 86b3f2f08e
Bug 40305: Fix 'tendered' vs 'collected' variable name inconsistency
"One Ring to rule them all, one Ring to find them, One Ring to bring
them all and in the darkness bind them"

We've been battling against this for years, with a mixed use of
terminology and thus confusion in templates vs controllers and notice
templates.  I've decided to just try and make sure all the terminology
matches throughout, and use the more popular 'tendered' term over the
'collected' term.

This patch standardizes the terminology used throughout the payment
  system to consistently use 'tendered' instead of the mixed usage of
  'collected' and 'tendered' that has caused confusion over the years.

Changes include:
  - Update all payment form templates to use 'tendered' input names
  - Update JavaScript validation and change calculation logic
  - Update controller parameter handling in pos/pay.pl, pos/printreceipt.pl,
    and members/paycollect.pl
  - Update sample notice templates (RECEIPT) to use 'tendered' variable
  - Add null check for $total_tendered to prevent perl warnings

Test plan:
  1. Test Point of Sale payments with tendered amounts and change calculation
  2. Test member account payments with tendered amounts
  3. Test receipt generation (both print and email)
  4. Verify JavaScript validation works correctly
  5. Confirm no perl warnings when tendered amount is undefined

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f91310306c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:24 +02:00
Lucas Gass ebb450e036
Bug 36561: Add new permission to t/Koha/Auth/Permissions.t test
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d801d4b16a)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:23 +02:00
Paul Derscheid ff135b5110
Bug 36561: DBRev 25.05.03.004
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:23 +02:00
David Cook d096290426
Bug 36561: Make /auth/password/validation use new permission
This patch updates the /auth/password/validation endpoint to use the new
api_validate_password permission instead of the generic borrowers
permission.

This provides more granular control over who can use the password
validation API endpoint.

To test:
1. Apply this patches
2. Rebuild the API spec
   $ ktd --shell
  k$ yarn api:bundle
3. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/password_validation.t
=> SUCCESS: Tests pass!
4. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 812b38d02c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:23 +02:00
David Cook 9c4319d2cf
Bug 36561: Add new permission `api_validate_password`
This change adds a `api_validate_password` permission which allows a user to only
validate borrowers by using the /api/v1/auth/password/validation endpoint.

This avoids scenarios where you want third-parties to authenticate a user without
giving them full permissions to perform CRUD operations on user data.

To test:
1. Apply patch
2. Run "koha-upgrade-schema kohadev"
3. koha-plack --reload kohadev
4. prove -v t/db_dependent/api/v1/password_validation.t
5. Visit http://localhost:8081/cgi-bin/koha/members/member-flags.pl?member=51
6. Note that a new subpermission `api_validate_password` appears under the "borrowers" permission

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 79c1853b2b)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:22 +02:00
Paul Derscheid c882d58649
Bug 37883: DBRev 25.05.03.003
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:22 +02:00
Lucas Gass c7420800a4
Bug 37883: (follow-up) Add a test
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 02aa7d08f2)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:21 +02:00
Lucas Gass 4a55f34dac
Bug 37883: (follow-up) Increment counts correctly
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit d6883d9e3c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:21 +02:00
Lucas Gass c7d5bad5c1
Bug 37883: Correct permissions of atomicupdate file
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4db82a99d0)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:20 +02:00
Lucas Gass 3e96cb4d11
Bug 37883: Fix branchspecific display of unavailable items
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a043b9f089)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:12 +02:00
Lucas Gass 085f2250a4
Bug 37883: A couple minor fixes to results.tt
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5607c2337f)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:12 +02:00
Lucas Gass 8904758228
Bug 37883: Use localStorage to remember user selection
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0a99176a4c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:12 +02:00
Lucas Gass 2ac88f0609
Bug 37883: Add FilterSearchResultsByLoggedInBranch system preference
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 764273befe)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:11 +02:00
Lucas Gass fe97075e4b
Bug 37883: Add ability to filter search results location column by logged in location
To test:

1. Apply patch, restart_all, and regenerate CSS ( https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_interface ) I also recommend clearing your browser cache.
2. Do a catalog search and notice the 'Show local items only' button above the "Location" column.
3. Click it to show information ( in that column ) that is only related to the branch you are currently logged in at.
4. In the same result set have some items that are checked out, withdrawn, lost, damaged, and notforlaon.
5. Play more with the search results and ensure everything is accurate.

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 580484e2da)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:11 +02:00
Lucas Gass 78f09d87bb
Bug 37883: Add logged in branch available, other, and onloan counts
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 0a22703807)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:10 +02:00
Lucas Gass 89f0c87a17
Bug Bug 37883: Adjust template for new system preference
Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 26438d4eec)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:10 +02:00
Paul Derscheid 2d2795d84c
Bug 40405: DBIC schema changes
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:10 +02:00
Paul Derscheid be4add9121
Bug 40405: DBRev 25.05.03.002
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:09 +02:00
Jonathan Druart 9df90e7c64
Bug 40405: And ILLOpacUnauthenticatedRequest
No idea why it was not NULL in DB when I did my first SELECT

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit fe14f8b7c6)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:09 +02:00
Jonathan Druart 5d5ccb8073
Bug 40405: Set decreaseLoanHighHolds\* to 0
When reviewing the different sysprefs that had "NULL" as default, I
only found those 2 occurrences that could be problematic. I think we
should default to 0 here.

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ca6cbc3cf9)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:09 +02:00
Jonathan Druart baf8af8c99
Bug 40405: Set systempreferences.value to NOT NULL
Some sysprefs have NULL as their default value, and systempreferences.value allows NULL values.

However C4::Context->set_preference does not unset a syspref if "undef" is passed.

Additionally some of the sysprefs that have NULL as default will generate warnings in the logs (and test suite output).

opac/opac-suggestions.pl:        for my $f ( split( /\s*\,\s*/, C4::Context->preference("OPACSuggestionUnwantedFields") ) ) {

Here is the current list:
+-------------------------------+-------+
| variable                      | value |
+-------------------------------+-------+
| decreaseLoanHighHoldsDuration | NULL  |
| decreaseLoanHighHoldsValue    | NULL  |
| ILLHiddenRequestStatuses      | NULL  |
| ILLOpacbackends               | NULL  |
| ILLSendStaffNotices           | NULL  |
| ListOwnerDesignated           | NULL  |
| MarcFieldDocURL               | NULL  |
| MaxFine                       | NULL  |
| OPACSuggestionUnwantedFields  | NULL  |
| ReportsExportLimit            | NULL  |
| SerialsSearchResultsLimit     | NULL  |
+-------------------------------+-------+

Test plan:
Code review required here, please confirm the above and that the
different occurrences do not use "undef" as a value.

Note that some tests now do not longer generate warnings
(eg. t/db_dependent/selenium/opac_ill_requests.t)

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a3b4b5cdd0)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:08 +02:00
Paul Derscheid a2bc913de0
Bug 23010: DBRev 25.05.03.001
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:08 +02:00
Lucas Gass f58bb7823c
Bug 23010: Adjust tests
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9fefdd5674)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:07 +02:00
Emily Lamancusa 24dab792e3
Bug 23010: (QA follow-up) a few trivial fixes
- Update the dbrev to use say_success, and make dbrev and installer
  consistent
- Change error div in moredetail.tt from info to warning

Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3096833130)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:07 +02:00
Lucas Gass 5965abb919
Bug 23010: More unit tests
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 7a299a8114)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:07 +02:00
Lucas Gass 772ad06f86
Bug 23010: Clean up try/catch in additem.pl
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit f14ab6ba9d)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:06 +02:00
Lucas Gass 820dbb3dfb
Bug 23010: Remove JS added by mistake
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 3656abadad)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:06 +02:00
Lucas Gass 0dea596fbb
Bug 23010: Add tests for AutomaticItemModificationByAge
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 7bc9a02bd2)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:06 +02:00
Lucas Gass c6986364ef
Bug 23010: Handle error in C4/Items.pm using try/catch
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 316f8bc4b8)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:05 +02:00
Lucas Gass 845171e4aa
Bug 23010: Report on count of items not modified via batchMod
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit ccf4bc0626)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:05 +02:00
Lucas Gass af9615f3d9
Bug 23010: Update pref name to PreventWithdrawingItemsStatus
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit c4acafe29b)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:04 +02:00
Lucas Gass 22b32b2814
Bug 23010: Fix file permission of atomicupdate
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e5da98c353)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:04 +02:00
Lucas Gass 5aef212975
Bug 23010: Add unit tests
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit b035515d1a)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:04 +02:00
Lucas Gass 09fc5e8468
Bug 23010: Handle error in updateitem.pl and template
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 73505a73ec)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:03 +02:00
Lucas Gass 152af99174
Bug 23010: Add ability to block withdrawning of items with certain statuses
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit b74dbf3d59)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:02:03 +02:00
Lucas Gass db1bca48e6
Bug 23010: Add system preference PreventWithdrawingItemsStatus
To test:

1. APPLY PATCH, updatedatabase, and restart_all
2. Search for the system preference, PreventWithDrawingItemsStatus
3. Select both in transit and checked out, then save
4. Find an item and put it in transit.
5. Now from the item detail page, go to manage items > edit item
6. Using the item that was put in transit, attempt to change the status to withdrawn.
7. You should see an error at the top of the page 'In transit item cannot be withdrawn.' Make sure the item did not get marked as withdrawn.
8. Using a different item, do a checkout
9. Now from the item detail page, go to manage items > edit item
10. Using the checked out item, attempt to change the status to withdrawn.
11. vYou should see an error at the top of the page 'Onloan item cannot be withdrawn.' Make sure the item did not get marked as withdrawn.

12. Now, using the in transit item, go to the items tab. ( catalogue/moredetail.pl?biblionumber=x )
13. Under Statuses, attempt to withdraw the item.
14. You should see an error near the top of the page "Cannot withdraw item in transit".
15. Now, using the checked out item, go to the items tab. ( catalogue/moredetail.pl?biblionumber=144 )
16. Under Statuses, attempt to withdraw the item.
17. You should see an error near the top of the page "Cannot withdraw checked out item.".

18. Using both the in-transit and checked out item, attempt to modify the status through batchMod.
19. Ensure that the items are not being updated to withdrawn.

20. Turn off PreventWithDrawingItemsStatus system preferece.
21. Going through each of the steps again, except this time your items should successfully withdraw.

prove t/db_dependent/Koha/Item.t

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4e920be91f)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-09-16 14:01:58 +02:00
Paul Derscheid d528562116
Update release notes for 25.05.03 release
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:55:25 +02:00
Paul Derscheid a7d9b27728
Increment version for 25.05.03 release
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:47:58 +02:00
Tomas Cohen Arazi 8b494a3789
Bug 40579: Fix CSV formula injection vulnerabilities
This patch addresses CSV formula injection vulnerabilities by ensuring
all Text::CSV instances use formula protection.

Changes made:
* Add formula => 'empty' to all Text::CSV constructors in:
  - Koha::Patrons::Import
  - Koha::BackgroundJob::ImportKBARTFile
  - Koha::ERM::EUsage::CounterFile

The 'empty' formula mode causes potentially dangerous formulas (starting
with =, +, -, @) to be treated as empty strings rather than executed,
preventing CSV injection attacks while maintaining data integrity.

Security impact:
* Prevents execution of malicious formulas in CSV imports
* Protects against data exfiltration via CSV formula injection
* Maintains backward compatibility for legitimate CSV data

To test:
1. Apply the previous patch (author test)
2. Run:
   $ ktd --shell
  k$ prove xt/author/Text_CSV_Various.t
=> FAIL: Should show 3 files without formula protection
3. Apply this patch
4. Repeat 2
=> SUCCESS: All tests should now pass
5. Try importing CSV with formula content (=cmd|"/c calc",test,data)
=> SUCCESS: Formula content is rejected/emptied, not executed
6. Import normal CSV data
=> SUCCESS: Normal data imports correctly
7. Sign off :-D

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:14 +02:00
Tomas Cohen Arazi a07ffbf3d9
Bug 40579: Add author test for CSV formula injection protection
This test ensures all Text::CSV usage in Koha includes proper formula
injection protection to prevent CSV formula injection attacks.

The test scans all Perl modules and verifies that Text::CSV constructors
include the 'formula' parameter set to a safe mode ('empty', 'die',
'croak', 'diag', or numeric 1-5).

To test:
1. Apply this patch
2. Run:
   $ ktd --shell
  k$ prove xt/author/Text_CSV_Various.t
=> FAIL: Test should fail showing files without formula protection:
   - Koha/Patrons/Import.pm
   - Koha/BackgroundJob/ImportKBARTFile.pm
   - Koha/ERM/EUsage/CounterFile.pm
3. Apply the follow-up patch to fix the violations
4. Repeat 2
=> SUCCESS: All tests should pass
5. Sign off :-D

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:13 +02:00
Jonathan Druart 441c5ef081
Bug 40538: Simplify code
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:13 +02:00
David Cook 39daea4c76
Bug 40538: Fix XSS in suspend hold modal
This patch fixes a XSS vulnerability in the
suspend hold modal in the staff interface.

By building our Javascript using Web APIs rather
than with strings and jQuery's html() method,
we're able to securely handle malicious payloads.

Test plan:
0. Apply the patch
1. Go to http://localhost:8081/cgi-bin/koha/reserve/request.pl?biblionumber=29
2. Add a hold for "koha" patron
3. Go to http://localhost:8081/cgi-bin/koha/circ/circulation.pl?borrowernumber=51
4. Click "Holds" tab and click "Suspend"
5. Note the modal loads properly
6. Go to http://localhost:8081/cgi-bin/koha/members/moremember.pl?borrowernumber=51
7. Click "Holds" tab and click "Suspend"
8. Note the modal loads properly

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:13 +02:00
Marcel de Rooy f09fe9e56c
Bug 39906: (QA follow-up) Feature needs to be enabled specifically
See also comment33, point 4.

Test plan:
cp debian/templates/apache-shared-opac-antibot.conf /etc/koha/
Test enabling/disabling by toggling the comment of the SetEnvIf line,
restart apache and remove the KOHA_INIT and CGISESSID cookie.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:12 +02:00
David Cook 89cb4ef77b
Bug 39906: Add a simple quick Apache-level bot challenge
This patch adds a fast simple bot challenge via Apache.

To test:
0. Apply the patch
1. sudo cp debian/templates/apache-shared-opac-antibot.conf /etc/koha/.
2. sudo cp debian/templates/apache-shared-opac-plack.conf /etc/koha/.
3. curl http://localhost:8080/cgi-bin/koha/opac-search.pl
4. Note an instant response with a very simple HTML response
5. Open an incognito browser and go to http://localhost:8080/cgi-bin/koha/opac-search.pl
6. Note a very brief loading animation before the OPAC search page appearing
7. Do a search
8. Note no more loading animation appears
9. Close the incognito browser
10. Open an incognito browser and go to http://localhost:8080/cgi-bin/koha/opac-main.pl
11. Do a search via the "Library catalog" search bar
12. Note no loading animation appears

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Cornelius Hertfelder <cornelius.hertfelder@bsz-bw.de>
Signed-off-by: Magnus Enger <magnus@libriotech.no>
We have tested this in production on at least three live sites for
several weeks, and it has worked as expected. We have not noticed any
negative side effects.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 21:05:08 +02:00
Lisette Scheer 642802d8cd
Bug 40620: Holds Queue will assign to the lowest item number if multiple branches have the same transport cost
To Test:
Before applying:
1. Turn on the UseTransportCostMatrix system preference
2. Create holds on a record with multiple items. (I used Lanark in KTD)
3. Set the item location to all be the same (I used MID)
4. Set the holds to pickup at Centerville, Fairfield, and Pleasant Valley
5. Set the transport cost matrix to
Centerville\fairfield 1
Centerville\Midway 1
Fairfield\Centerville 1
Fairfield\Midway 1
Midway\Centerville 1
Midway\Fairfield 1
Midway\Pleasant Valley 4

6. Build the holds queue (either turn on realtime hold queue and then edit the bib to update or run the cron on the command line)
7. Run a report: select * from hold_fill_targets where biblionumber=9 order by borrowernumber;
8. Rebuild the hold queue
9. Run the report again, the results should be the same.

10. Apply the patch
11. Run the hold queue again
12. Observe the results should now be different.
13. Try a few more times and ensure the numbers are changing, create some more items at midway and try again to see more variety in numbers.

Signed-off-by: David Flater <flaterdavid@gmail.com>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 5832521086)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 20:37:29 +02:00
Lucas Gass 4844ce3f18
Bug 40654: Adjust display to show current priority
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 58dc43e06e)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 20:37:28 +02:00
Lucas Gass 369f8ae6e2
Bug 40654: Fix how rank/priority is adjusted when changing from the UI
To test:
0 - APPLY PATCH
1 - Place 50 holds on a bib record
https://github.com/kidclamp/handy-koha-script/blob/main/randhold.pl
2 - View the holds page for the record
3 - Sort the holds alphabetically
4 - Change the dropdown priortiy for the alphabetically first hold to 1
5 - All the priorities should now ajust accordingly but they will NOT be resorted on the fly
6 - Play with adjusting some priorities, making sure everything correctly adjusts.
7 - Click 'Update holds' to make sure the priorities adjust right
8 - Make sure you test with the 'del' option and the adjustments still work.

Signed-off-by: David Flater <flaterdavid@gmail.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 4b38f5acd5)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
2025-08-26 20:37:28 +02:00