r6741 - in /trunk/libarchive-tar-perl: CHANGES META.yml debian/changelog lib/Archive/Tar.pm lib/Archive/Tar/File.pm t/03_file.t

rmayorga-guest at users.alioth.debian.org rmayorga-guest at users.alioth.debian.org
Fri Aug 17 07:02:35 UTC 2007


Author: rmayorga-guest
Date: Fri Aug 17 07:02:35 2007
New Revision: 6741

URL: http://svn.debian.org/wsvn/?sc=1&rev=6741
Log:
* New upstream version

Modified:
    trunk/libarchive-tar-perl/CHANGES
    trunk/libarchive-tar-perl/META.yml
    trunk/libarchive-tar-perl/debian/changelog
    trunk/libarchive-tar-perl/lib/Archive/Tar.pm
    trunk/libarchive-tar-perl/lib/Archive/Tar/File.pm
    trunk/libarchive-tar-perl/t/03_file.t

Modified: trunk/libarchive-tar-perl/CHANGES
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/CHANGES?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/CHANGES (original)
+++ trunk/libarchive-tar-perl/CHANGES Fri Aug 17 07:02:35 2007
@@ -1,8 +1,17 @@
+* important changes in version 1.34 15/8/2007:
+-   Address #28687: Fwd: Unespected reaction of Archive::Tar
+    A::T didn't always handle filenames that evaluated to false 
+    (like '0') gracefully. This patch adds a few 'or defined' check 
+    to the A::T codebase and a test to ensure filenames like '0' are 
+    handeled correctly.
+-   Apply #28407: Unicode and Archive::Tar - documentation patch as
+	FAQ patch
+
 * important changes in version 1.32 24/5/2007:
 -   Make Archive::Tar work nicely with perls compiled with 
     -Dmksymlinks. This also fixes an issue introduced in 
     1.31 where symlinks weren't dereferenced in all cases.
--   Quell warnings when a gid is not resolvable to a group name  
+-   Quell warnings when a gid is not resolvable to a group name 
 
 * important changes in version 1.31 18/5/2007:
 -   No longer use the t/setup.t and t/cleanup.t files but just bundle 

Modified: trunk/libarchive-tar-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/META.yml?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/META.yml (original)
+++ trunk/libarchive-tar-perl/META.yml Fri Aug 17 07:02:35 2007
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Archive-Tar
-version:      1.32
+version:      1.34
 version_from: lib/Archive/Tar.pm
 installdirs:  site
 requires:

Modified: trunk/libarchive-tar-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/debian/changelog?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/debian/changelog (original)
+++ trunk/libarchive-tar-perl/debian/changelog Fri Aug 17 07:02:35 2007
@@ -1,3 +1,9 @@
+libarchive-tar-perl (1.34-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Rene Mayorga <rmayorga at debian.org.sv>  Fri, 17 Aug 2007 00:39:07 -0600
+
 libarchive-tar-perl (1.32-1) unstable; urgency=low
 
   * [Rene Mayorga]

Modified: trunk/libarchive-tar-perl/lib/Archive/Tar.pm
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/lib/Archive/Tar.pm?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/lib/Archive/Tar.pm (original)
+++ trunk/libarchive-tar-perl/lib/Archive/Tar.pm Fri Aug 17 07:02:35 2007
@@ -14,7 +14,7 @@
 $DEBUG              = 0;
 $WARN               = 1;
 $FOLLOW_SYMLINK     = 0;
-$VERSION            = "1.32";
+$VERSION            = "1.34";
 $CHOWN              = 1;
 $CHMOD              = 1;
 $DO_NOT_USE_PREFIX  = 0;
@@ -406,7 +406,9 @@
 
 sub contains_file {
     my $self = shift;
-    my $full = shift or return;
+    my $full = shift;
+    
+    return unless defined $full;
 
     ### don't warn if the entry isn't there.. that's what this function
     ### is for after all.
@@ -509,7 +511,7 @@
 
 sub extract_file {
     my $self = shift;
-    my $file = shift or return;
+    my $file = shift;   return unless defined $file;
     my $alt  = shift;
 
     my $entry = $self->_find_entry( $file )
@@ -1669,6 +1671,56 @@
     $tar->write($fh);
     $fh->close ;
 
+=item How do I handle Unicode strings?
+
+C<Archive::Tar> uses byte semantics for any files it reads from or writes
+to disk. This is not a problem if you only deal with files and never
+look at their content or work solely with byte strings. But if you use
+Unicode strings with character semantics, some additional steps need
+to be taken.
+
+For example, if you add a Unicode string like
+
+    # Problem
+    $tar->add_data('file.txt', "Euro: \x{20AC}");
+
+then there will be a problem later when the tarfile gets written out
+to disk via C<$tar->write()>:
+
+    Wide character in print at .../Archive/Tar.pm line 1014.
+
+The data was added as a Unicode string and when writing it out to disk,
+the C<:utf8> line discipline wasn't set by C<Archive::Tar>, so Perl
+tried to convert the string to ISO-8859 and failed. The written file
+now contains garbage.
+
+For this reason, Unicode strings need to be converted to UTF-8-encoded
+bytestrings before they are handed off to C<add_data()>:
+
+    use Encode;
+    my $data = "Accented character: \x{20AC}";
+    $data = encode('utf8', $data);
+
+    $tar->add_data('file.txt', $data);
+
+A opposite problem occurs if you extract a UTF8-encoded file from a 
+tarball. Using C<get_content()> on the C<Archive::Tar::File> object
+will return its content as a bytestring, not as a Unicode string.
+
+If you want it to be a Unicode string (because you want character
+semantics with operations like regular expression matching), you need
+to decode the UTF8-encoded content and have Perl convert it into 
+a Unicode string:
+
+    use Encode;
+    my $data = $tar->get_content();
+    
+    # Make it a Unicode string
+    $data = decode('utf8', $data);
+
+There is no easy way to provide this functionality in C<Archive::Tar>, 
+because a tarball can contain many files, and each of which could be
+encoded in a different way.
 
 =back
 

Modified: trunk/libarchive-tar-perl/lib/Archive/Tar/File.pm
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/lib/Archive/Tar/File.pm?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/lib/Archive/Tar/File.pm (original)
+++ trunk/libarchive-tar-perl/lib/Archive/Tar/File.pm Fri Aug 17 07:02:35 2007
@@ -200,7 +200,7 @@
 
 sub _new_from_chunk {
     my $class = shift;
-    my $chunk = shift or return;
+    my $chunk = shift or return;    # 512 bytes of tar header
     my %hash  = @_;
 
     ### filter any arguments on defined-ness of values.
@@ -233,7 +233,11 @@
 
 sub _new_from_file {
     my $class       = shift;
-    my $path        = shift or return;
+    my $path        = shift;        
+    
+    ### path has to at least exist
+    return unless defined $path;
+    
     my $type        = __PACKAGE__->_filetype($path);
     my $data        = '';
 
@@ -304,7 +308,7 @@
 
 sub _new_from_data {
     my $class   = shift;
-    my $path    = shift     or return;
+    my $path    = shift;    return unless defined $path;
     my $data    = shift;    return unless defined $data;
     my $opt     = shift;
 
@@ -371,7 +375,9 @@
 
 sub _filetype {
     my $self = shift;
-    my $file = shift or return;
+    my $file = shift;
+    
+    return unless defined $file;
 
     return SYMLINK  if (-l $file);	# Symlink
 
@@ -515,7 +521,9 @@
 
 sub rename {
     my $self = shift;
-    my $path = shift or return;
+    my $path = shift;
+    
+    return unless defined $path;
 
     my ($prefix,$file) = $self->_prefix_and_file( $path );
 

Modified: trunk/libarchive-tar-perl/t/03_file.t
URL: http://svn.debian.org/wsvn/trunk/libarchive-tar-perl/t/03_file.t?rev=6741&op=diff
==============================================================================
--- trunk/libarchive-tar-perl/t/03_file.t (original)
+++ trunk/libarchive-tar-perl/t/03_file.t Fri Aug 17 07:02:35 2007
@@ -20,6 +20,10 @@
     [    'x/bIn1',        $all_chars                                      ],
     [    'bIn2',          $all_chars x 2                                  ],
     [    'bIn0',          ''                                              ],
+
+    ### we didnt handle 'false' filenames very well across A::T as of version
+    ### 1.32, as reported in #28687. Test for the handling of such files here.
+    [    0,               '',                                             ],
     
     ### keep this one as the last entry
     [    'x/yy/z',        '',               { type  => DIR,




More information about the Pkg-perl-cvs-commits mailing list