commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1304717 - in /commons/proper/compress/trunk/src: main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
Date Sat, 24 Mar 2012 06:23:33 GMT
Author: bodewig
Date: Sat Mar 24 06:23:33 2012
New Revision: 1304717

URL: http://svn.apache.org/viewvc?rev=1304717&view=rev
Log:
support for non-ASCII linkpath in PAX headers

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
    commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java?rev=1304717&r1=1304716&r2=1304717&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStream.java
Sat Mar 24 06:23:33 2012
@@ -302,6 +302,12 @@ public class TarArchiveOutputStream exte
             paxHeaders.put("path", entryName);
         }
 
+        if (addPaxHeadersForNonAsciiNames
+            && (entry.isLink() || entry.isSymbolicLink())
+            && !ASCII.canEncode(entry.getLinkName())) {
+            paxHeaders.put("linkpath", entry.getLinkName());
+        }
+
         if (paxHeaders.size() > 0) {
             writePaxHeaders(entryName, paxHeaders);
         }

Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java?rev=1304717&r1=1304716&r2=1304717&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
(original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveOutputStreamTest.java
Sat Mar 24 06:23:33 2012
@@ -294,4 +294,25 @@ public class TarArchiveOutputStreamTest 
         assertEquals(n, e.getName());
     }
 
+    public void testWriteNonAsciiLinkPathNamePaxHeader() throws Exception {
+        String n = "\u00e4";
+        TarArchiveEntry t = new TarArchiveEntry("a", TarConstants.LF_LINK);
+        t.setSize(10 * 1024);
+        t.setLinkName(n);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        TarArchiveOutputStream tos = new TarArchiveOutputStream(bos);
+        tos.setAddPaxHeadersForNonAsciiNames(true);
+        tos.putArchiveEntry(t);
+        tos.write(new byte[10 * 1024]);
+        tos.closeArchiveEntry();
+        tos.close();
+        byte[] data = bos.toByteArray();
+        assertEquals("15 linkpath=" + n + "\n",
+                     new String(data, 512, 15, "UTF-8"));
+        TarArchiveInputStream tin =
+            new TarArchiveInputStream(new ByteArrayInputStream(data));
+        TarArchiveEntry e = tin.getNextTarEntry();
+        assertEquals(n, e.getLinkName());
+    }
+
 }
\ No newline at end of file



Mime
View raw message