Bugzilla – Attachment 121851 Details for
Bug 28489
CGI::Session is incorrectly serialized to DB in production env / when strict_sql_modes = 0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28489: POD - CGI::Session::Serialize::yamlxs for CGI::Session
Bug-28489-POD---CGISessionSerializeyamlxs-for-CGIS.patch (text/plain), 2.93 KB, created by
Jonathan Druart
on 2021-06-11 14:05:23 UTC
(
hide
)
Description:
Bug 28489: POD - CGI::Session::Serialize::yamlxs for CGI::Session
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-06-11 14:05:23 UTC
Size:
2.93 KB
patch
obsolete
>From 86c3ce887f215a223418474899f6e07b9a14de1e Mon Sep 17 00:00:00 2001 >From: Andrew Nugged <nugged@gmail.com> >Date: Fri, 4 Jun 2021 22:32:22 +0300 >Subject: [PATCH] Bug 28489: POD - CGI::Session::Serialize::yamlxs for > CGI::Session > >Signed-off-by: David Cook <dcook@prosentient.com.au> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Auth.pm | 37 +++++++++++++++++++++++++++++++++---- > 1 file changed, 33 insertions(+), 4 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index f281def2ce0..cf254ba60ef 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1,3 +1,32 @@ >+package CGI::Session::Serialize::yamlxs; >+# Proof of concept: CGI::Session::Serialize::yamlxs for CGI::Session: >+ >+use strict; >+use warnings; >+ >+# hacky hack to trick CGI::Session loader for serializers not to die in its "require": >+$INC{'CGI/Session/Serialize/yamlxs.pm'} = '1'; >+ >+use CGI::Session::ErrorHandler; >+use YAML::XS (); >+use Encode (); >+ >+$CGI::Session::Serialize::yamlxs::VERSION = '0.1'; >+@CGI::Session::Serialize::yamlxs::ISA = ( "CGI::Session::ErrorHandler" ); >+ >+sub freeze { >+ my ($self, $data) = @_; >+ return Encode::decode_utf8(YAML::XS::Dump($data)); >+} >+ >+sub thaw { >+ my ($self, $string) = @_; >+ return (YAML::XS::Load(Encode::encode_utf8($string)))[0]; >+} >+# ******************************************************************** >+ >+ >+ > package C4::Auth; > > # Copyright 2000-2002 Katipo Communications >@@ -1850,21 +1879,21 @@ sub _get_session_params { > my $storage_method = C4::Context->preference('SessionStorage'); > if ( $storage_method eq 'mysql' ) { > my $dbh = C4::Context->dbh; >- return { dsn => "driver:MySQL;id:md5", dsn_args => { Handle => $dbh } }; >+ return { dsn => "serializer:yamlxs;driver:MySQL;id:md5", dsn_args => { Handle => $dbh } }; > } > elsif ( $storage_method eq 'Pg' ) { > my $dbh = C4::Context->dbh; >- return { dsn => "driver:PostgreSQL;id:md5", dsn_args => { Handle => $dbh } }; >+ return { dsn => "serializer:yamlxs;driver:PostgreSQL;id:md5", dsn_args => { Handle => $dbh } }; > } > elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) { > my $memcached = Koha::Caches->get_instance()->memcached_cache; >- return { dsn => "driver:memcached;id:md5", dsn_args => { Memcached => $memcached } }; >+ return { dsn => "serializer:yamlxs;driver:memcached;id:md5", dsn_args => { Memcached => $memcached } }; > } > else { > # catch all defaults to tmp should work on all systems > my $dir = C4::Context::temporary_directory; > my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is >- return { dsn => "driver:File;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } }; >+ return { dsn => "serializer:yamlxs;driver:File;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } }; > } > } > >-- >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 28489
:
121539
|
121541
|
121563
|
121564
|
121565
|
121570
|
121571
|
121584
|
121585
|
121624
|
121637
|
121638
|
121639
|
121640
|
121648
|
121650
|
121651
|
121652
|
121653
|
121654
|
121831
|
121832
|
121833
|
121834
|
121835
|
121848
|
121849
|
121850
| 121851 |
121852