Bugzilla – Attachment 138448 Details for
Bug 27849
Koha::Token may access undefined C4::Context->userenv
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27849: Koha::Token may access undefined C4::Context->userenv
Bug-27849-KohaToken-may-access-undefined-C4Context.patch (text/plain), 1.86 KB, created by
Marcel de Rooy
on 2022-08-01 08:12:05 UTC
(
hide
)
Description:
Bug 27849: Koha::Token may access undefined C4::Context->userenv
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-08-01 08:12:05 UTC
Size:
1.86 KB
patch
obsolete
>From af145c4bf6c01a6d1b1de3d6d1869e5927f06ffb Mon Sep 17 00:00:00 2001 >From: MJ Ray <mjr@phonecoop.coop> >Date: Wed, 3 Mar 2021 17:54:42 +0000 >Subject: [PATCH] Bug 27849: Koha::Token may access undefined > C4::Context->userenv >Content-Type: text/plain; charset=utf-8 > >The _add_default_csrf_params internal function accesses >C4::Context->userenv without checking that it has been defined. I think >not all of the potential callers of it declare that they require a >defined userenv, so we should test and provide defaults for required >values if it is not defined, to avoid some "Can't use an undefined value >as a HASH reference" HTTP 500 Internal Server Errors. > >To test: > >Do anything that requires a form with CSRF token, such as editing your >details. Behaviour should be unchanged. To test the failure case, you >would need some customised code that indirectly generates a CSRF token >before setting the userenv up and I am not sure there is any in released >Koha yet. > >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> > >Looks good to me. Working as expected. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Token.pm | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > >diff --git a/Koha/Token.pm b/Koha/Token.pm >index f4334a7223..866bfc3ae4 100644 >--- a/Koha/Token.pm >+++ b/Koha/Token.pm >@@ -214,7 +214,11 @@ sub _add_default_csrf_params { > my ( $params ) = @_; > $params->{session_id} //= ''; > if( !$params->{id} ) { >- $params->{id} = Encode::encode( 'UTF-8', C4::Context->userenv->{id} . $params->{session_id} ); >+ if( defined( C4::Context->userenv ) ) { >+ $params->{id} = Encode::encode( 'UTF-8', C4::Context->userenv->{id} . $params->{session_id} ); >+ } else { >+ $params->{id} = Encode::encode( 'UTF-8', $params->{session_id} ); >+ } > } else { > $params->{id} .= $params->{session_id}; > } >-- >2.20.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 27849
:
117744
|
137802
| 138448 |
138449