summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Bodewig <stefan.bodewig@innoq.com>2022-11-26 17:23:20 +0100
committerStefan Bodewig <stefan.bodewig@innoq.com>2022-11-26 17:23:20 +0100
commit22ef1323cc2e38505dcfde911939cd92b6539dd5 (patch)
tree83a40003f1274cbaeefafcdd229d2975b69d2ae5
parent3e6d6acc38a47aa66e629e519f482ee975dd0480 (diff)
downloadant-22ef1323cc2e38505dcfde911939cd92b6539dd5.tar.gz
warn against multi-byte encoding in tar
-rw-r--r--manual/Tasks/tar.html5
-rw-r--r--src/etc/testcases/taskdefs/untar.xml8
-rw-r--r--src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java8
3 files changed, 20 insertions, 1 deletions
diff --git a/manual/Tasks/tar.html b/manual/Tasks/tar.html
index 88d3c3a73..985625b32 100644
--- a/manual/Tasks/tar.html
+++ b/manual/Tasks/tar.html
@@ -133,7 +133,10 @@ to <q>gzip</q>, <q>bzip2</q>, or <q>xz</q>.</p>
<td>The character encoding to use for filenames inside the tar file. For a list of possible
values see
the <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html"
- target="_top">Supported Encodings</a>.<br/><em>Since Ant 1.9.5</em>
+ target="_top">Supported Encodings</a>. In general the tar format
+ expects names to use a single byte encoding and specifying a
+ multi-byte encoding here may lead to archives that cannot be
+ properly extracted by my tar tools.<br/><em>Since Ant 1.9.5</em>
<td>No; defaults to default JVM character encoding</td>
</tr>
</table>
diff --git a/src/etc/testcases/taskdefs/untar.xml b/src/etc/testcases/taskdefs/untar.xml
index a443e120d..1255d9d87 100644
--- a/src/etc/testcases/taskdefs/untar.xml
+++ b/src/etc/testcases/taskdefs/untar.xml
@@ -60,6 +60,14 @@
<target name="encodingTest">
<mkdir dir="${output}/untartestin"/>
<touch file="${output}/untartestin/foo"/>
+ <tar tarfile="${output}/untartest.tar" basedir="${output}/untartestin" encoding="Cp1251"/>
+ <mkdir dir="${output}/untartestout"/>
+ <untar src="${output}/untartest.tar" dest="${output}/untartestout" encoding="Cp1251"/>
+ </target>
+
+ <target name="multiByteEncodingTest">
+ <mkdir dir="${output}/untartestin"/>
+ <touch file="${output}/untartestin/foo"/>
<tar tarfile="${output}/untartest.tar" basedir="${output}/untartestin" encoding="UnicodeBig"/>
<mkdir dir="${output}/untartestout"/>
<untar src="${output}/untartest.tar" dest="${output}/untartestout" encoding="UnicodeBig"/>
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
index 6a1cca457..4f414f877 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
@@ -86,6 +86,14 @@ public class UntarTest {
}
@Test
+ public void testMultiByteEncoding() {
+ buildRule.executeTarget("multiByteEncodingTest");
+ String filename = buildRule.getProject().getProperty("output") + "/untartestout/foo";
+ assertTrue("foo has been properly named",
+ buildRule.getProject().resolveFile(filename).exists());
+ }
+
+ @Test
public void testResourceCollection() throws IOException {
testLogoExtraction("resourceCollection");
}