]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - lib/File/KDBX/Dumper/XML.pm
Prereq Time::Piece 1.33 to fix KDBX4 datetimes
[chaz/p5-File-KDBX] / lib / File / KDBX / Dumper / XML.pm
index 07f388857d48b5f2cb8052f543743734c115ae74..c7ff83007b683a6cf8baf32729bd49352b1ba2e0 100644 (file)
@@ -9,10 +9,10 @@ use Crypt::Misc 0.029 qw(encode_b64);
 use Encode qw(encode);
 use File::KDBX::Constants qw(:version :time);
 use File::KDBX::Error;
-use File::KDBX::Util qw(:class assert_64bit erase_scoped gzip snakify);
+use File::KDBX::Util qw(:class :int erase_scoped gzip snakify);
 use IO::Handle;
 use Scalar::Util qw(blessed isdual looks_like_number);
-use Time::Piece;
+use Time::Piece 1.33;
 use XML::LibXML;
 use boolean;
 use namespace::clean;
@@ -62,8 +62,8 @@ the authenticity of header data. This is unnecessary and should not be used with
 format uses HMAC-SHA256 to detect tampering.
 
 L<File::KDBX::Dumper::V3> automatically calculates the header hash an provides it to this module, and plain
-XML files which don't have a KDBX wrapper don't have headers and so should have a header hash. Therefore there
-is probably never any reason to set this manually.
+XML files which don't have a KDBX wrapper don't have headers and so should not have a header hash. Therefore
+there is probably never any reason to set this manually.
 
 =cut
 
@@ -178,8 +178,8 @@ sub _write_xml_binaries {
     my $new_ref = keys %{$self->_binaries_written};
     my $written = $self->_binaries_written;
 
-    my $entries = $kdbx->all_entries(history => true);
-    for my $entry (@$entries) {
+    my $entries = $kdbx->entries(history => 1);
+    while (my $entry = $entries->next) {
         for my $key (keys %{$entry->binaries}) {
             my $binary = $entry->binaries->{$key};
             if (defined $binary->{ref} && defined $kdbx->binaries->{$binary->{ref}}) {
@@ -296,7 +296,7 @@ sub _write_xml_root {
 
     if (my $group = $kdbx->root) {
         my $group_node = $node->addNewChild(undef, 'Group');
-        $self->_write_xml_group($group_node, $group->_confirmed);
+        $self->_write_xml_group($group_node, $group->_committed);
     }
 
     undef $guard;   # re-lock if needed, as early as possible
@@ -337,12 +337,12 @@ sub _write_xml_group {
 
     for my $entry (@{$group->entries}) {
         my $entry_node = $node->addNewChild(undef, 'Entry');
-        $self->_write_xml_entry($entry_node, $entry->_confirmed);
+        $self->_write_xml_entry($entry_node, $entry->_committed);
     }
 
     for my $group (@{$group->groups}) {
         my $group_node = $node->addNewChild(undef, 'Group');
-        $self->_write_xml_group($group_node, $group->_confirmed);
+        $self->_write_xml_group($group_node, $group->_committed);
     }
 }
 
@@ -423,7 +423,7 @@ sub _write_xml_entry {
             my $history_node = $node->addNewChild(undef, 'History');
             for my $historical (@history) {
                 my $historical_node = $history_node->addNewChild(undef, 'Entry');
-                $self->_write_xml_entry($historical_node, $historical->_confirmed, 1);
+                $self->_write_xml_entry($historical_node, $historical->_committed, 1);
             }
         }
     }
@@ -571,9 +571,8 @@ sub _encode_datetime {
 
 sub _encode_datetime_binary {
     local $_ = shift;
-    assert_64bit;
     my $seconds_since_ad1 = $_ + TIME_SECONDS_AD1_TO_UNIX_EPOCH;
-    my $buf = pack('Q<', $seconds_since_ad1->epoch);
+    my $buf = pack_Ql($seconds_since_ad1->epoch);
     return eval { encode_b64($buf) };
 }
 
This page took 0.022433 seconds and 4 git commands to generate.