Bug 35960: Use .val() instead of string concat to prevent potential XSS

Test plan:
1. Log out
2. Go to /cgi-bin/koha/mainpage.pl#somestring"with<html>char
3. Open the brower's inspector and find "auth_forwarded_hash" input
4. Make sure the value attribute is there and corresponds to the URL's
   fragment. It should be URI-encoded.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
This commit is contained in:
Julian Maurice 2024-02-01 09:15:23 +01:00 committed by Wainui Witika-Park
parent 931a02f54a
commit dca99588e7
1 changed files with 3 additions and 1 deletions

View File

@ -185,7 +185,9 @@
<script>
$(document).ready( function() {
if ( document.location.hash ) {
$( '#loginform' ).append( '<input name="auth_forwarded_hash" type="hidden" value="' + document.location.hash + '"/>' );
const input = $('<input name="auth_forwarded_hash" type="hidden">')
input.val(document.location.hash);
$( '#loginform' ).append( input );
}
// Clear last borrowers, rememberd sql reports, carts, etc.
logOut();