Skip to content

Commit

Permalink
Use a different object for thawing
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Oct 3, 2024
1 parent 4ab1f69 commit 9f621d7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/pf/config/crypt/object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) = @_;
Expand All @@ -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;

Expand Down
59 changes: 59 additions & 0 deletions lib/pf/config/crypt/string.pm
Original file line number Diff line number Diff line change
@@ -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. <[email protected]>
=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;

0 comments on commit 9f621d7

Please sign in to comment.