From 9f621d7d74731fe439dd8ae182a7ea992b1f6020 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Thu, 3 Oct 2024 18:39:13 +0000 Subject: [PATCH] Use a different object for thawing --- lib/pf/config/crypt/object.pm | 11 +++---- lib/pf/config/crypt/string.pm | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 lib/pf/config/crypt/string.pm diff --git a/lib/pf/config/crypt/object.pm b/lib/pf/config/crypt/object.pm index b13d6d72e22..9ec31781392 100644 --- a/lib/pf/config/crypt/object.pm +++ b/lib/pf/config/crypt/object.pm @@ -13,7 +13,7 @@ pf::config::crypt::object use strict; use warnings; use pf::config::crypt; - +use pf::config::crypt::string; sub new { my ($proto, $data) = @_; @@ -24,18 +24,17 @@ sub new { sub THAW { my ($class, $serializer, $data) = @_; if (rindex($data, $pf::config::crypt::PREFIX, 0) == 0) { - my $result = pf::config::crypt::pf_decrypt($data); - #return $result; - return $class->new($result); + $data = pf::config::crypt::pf_decrypt($data); } - return $class->new($data); + + return pf::config::crypt::string->new($data); } sub TO_JSON { ${$_[0]} } -use overload +use overload '""' => \&stringify, fallback => 1; diff --git a/lib/pf/config/crypt/string.pm b/lib/pf/config/crypt/string.pm new file mode 100644 index 00000000000..ef101ded827 --- /dev/null +++ b/lib/pf/config/crypt/string.pm @@ -0,0 +1,59 @@ +package pf::config::crypt::string; + +=head1 NAME + +pf::config::crypt::string - + +=head1 DESCRIPTION + +pf::config::crypt::string + +=cut + +use strict; +use warnings; + +sub new { + my ($proto, $data) = @_; + my $class = ref($proto) || $proto; + return bless(\$data, $class) +} + +use overload + '""' => \&stringify, + fallback => 1; + + +sub stringify { + ${$_[0]} +} + +=head1 AUTHOR + +Inverse inc. + +=head1 COPYRIGHT + +Copyright (C) 2005-2024 Inverse inc. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +USA. + +=cut + +1; +