Bugzilla – Attachment 107588 Details for
Bug 20804
Sanitize input of timeout syspref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20804: Add support for "days" to the timeout syspref
Bug-20804-Add-support-for-days-to-the-timeout-sysp.patch (text/plain), 1.79 KB, created by
Jonathan Druart
on 2020-07-30 13:20:20 UTC
(
hide
)
Description:
Bug 20804: Add support for "days" to the timeout syspref
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-07-30 13:20:20 UTC
Size:
1.79 KB
patch
obsolete
>From 74b3ab50b16803481cb2acd7738f85f40e8e2aa4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 30 Jul 2020 15:15:46 +0200 >Subject: [PATCH] Bug 20804: Add support for "days" to the timeout syspref > >If the timeout syspref did not contain an integer, or was not matching >integer.'d|D', then it "fallback" to 0 > >We can easily add support for hours and fallback to 600 if the value is >not correct. >It will prevent the session to timeout immediately > >Test plan: >0. Do not apply the patches >1. Fill the timeout syspref with "5m" >2. Login >3. Click somewhere >=> Notice that the session timed out >4. Apply the patches, restart_all >5. Login >6. Click somewhere >=> You have 5 minutes to enjoy Koha >7. Fill the pref with an incorrect value ("5x" for instance) >8. Logout, login >9. There is a warning in the log, and you have 10 minutes to enjoy Koha >--- > C4/Auth.pm | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 259b6d6063..7b5a0cdd2b 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -764,12 +764,22 @@ sub _session_log { > } > > sub _timeout_syspref { >- my $timeout = C4::Context->preference('timeout') || 600; >+ my $default_timeout = 600; >+ my $timeout = C4::Context->preference('timeout') || $default_timeout; > > # value in days, convert in seconds >- if ( $timeout =~ /(\d+)[dD]/ ) { >+ if ( $timeout =~ /^(\d+)[dD]$/ ) { > $timeout = $1 * 86400; > } >+ # value in hours, convert in seconds >+ elsif ( $timeout =~ /^(\d+)[hH]$/ ) { >+ $timeout = $1 * 3600; >+ } >+ elsif ( $timeout !~ m/^\d+$/ ) { >+ warn "The value of the system preference 'timeout' is not correct, defaulting to $default_timeout"; >+ $timeout = $default_timeout; >+ } >+ > return $timeout; > } > >-- >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 20804
:
107587
|
107588
|
109688
|
111160
|
111161
|
111547
|
111548