X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FFile%2FKDBX%2FLoader%2FKDB.pm;h=685e0a9fcef83242e25d1c8ef39e548a70bfe637;hb=700fa117555b87eda7227f9083c0fc0df052c64f;hp=e204365266ae658b860ce5f4425243d7dadc0cf3;hpb=37b09e0f2832514b33de4499a83f22d5ffe7c0a3;p=chaz%2Fp5-File-KDBX diff --git a/lib/File/KDBX/Loader/KDB.pm b/lib/File/KDBX/Loader/KDB.pm index e204365..685e0a9 100644 --- a/lib/File/KDBX/Loader/KDB.pm +++ b/lib/File/KDBX/Loader/KDB.pm @@ -11,7 +11,7 @@ use File::KDBX::Util qw(:class :empty :io :uuid load_optional); use File::KDBX; use Ref::Util qw(is_arrayref is_hashref); use Scalar::Util qw(looks_like_number); -use Time::Piece; +use Time::Piece 1.33; use boolean; use namespace::clean; @@ -19,7 +19,7 @@ extends 'File::KDBX::Loader'; our $VERSION = '999.999'; # VERSION -my $DEFAULT_EXPIRATION = Time::Piece->new(32503677839); # 2999-12-31 23:59:59 +my $DEFAULT_EXPIRATION = Time::Piece->strptime('2999-12-31 23:59:59', '%Y-%m-%d %H:%M:%S'); sub _read_headers { '' } @@ -90,16 +90,18 @@ sub convert_keepass_to_kdbx { } } - for my $entry ($kdbx->find_entries({ + $kdbx->entries + ->grep({ title => 'Meta-Info', username => 'SYSTEM', url => '$', icon_id => 0, -nonempty => 'notes', - })) { - _read_meta_stream($kdbx, $entry); - $entry->remove; - } + }) + ->each(sub { + _read_meta_stream($kdbx, $_); + $_->remove(signal => 0); + }); return $kdbx; } @@ -120,7 +122,7 @@ sub _read_meta_stream { read_all $fh, $buf, 5 or goto PARSE_ERROR; my ($group_id, $expanded) = unpack('L< C', $buf); my $uuid = _decode_uuid($group_id) // next; - my ($group) = $kdbx->find_groups({uuid => $uuid}); + my $group = $kdbx->groups->grep({uuid => $uuid})->next; $group->is_expanded($expanded) if $group; } } @@ -139,7 +141,7 @@ sub _read_meta_stream { read_all $fh, $buf, 20 or goto PARSE_ERROR; my ($uuid, $icon_index) = unpack('a16 L<', $buf); next if !$icons[$icon_index]; - my ($entry) = $kdbx->find_entries({uuid => $uuid}); + my $entry = $kdbx->entries->grep({uuid => $uuid})->next; $entry->custom_icon_uuid($icons[$icon_index]) if $entry; } for (my $i = 0; $i < $num_groups; ++$i) { @@ -147,7 +149,7 @@ sub _read_meta_stream { my ($group_id, $icon_index) = unpack('L<2', $buf); next if !$icons[$icon_index]; my $uuid = _decode_uuid($group_id) // next; - my ($group) = $kdbx->find_groups({uuid => $uuid}); + my $group = $kdbx->groups->grep({uuid => $uuid})->next; $group->custom_icon_uuid($icons[$icon_index]) if $group; } } @@ -232,7 +234,7 @@ sub _convert_keepass_to_kdbx_headers { $meta->{settings_changed} = _decode_datetime($from->{settings_changed}); while (my ($key, $value) = each %{$from->{custom_icons} || {}}) { - $meta->{custom_icons}{$key} = {value => $value}; + push @{$meta->{custom_icons} //= []}, {uuid => $key, data => $value}; } while (my ($key, $value) = each %{$from->{custom_data} || {}}) { $meta->{custom_data}{$key} = {value => $value};