You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2022/11/26 16:23:45 UTC
[ant] branch master updated: warn against multi-byte encoding in tar
This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new 22ef1323c warn against multi-byte encoding in tar
22ef1323c is described below
commit 22ef1323cc2e38505dcfde911939cd92b6539dd5
Author: Stefan Bodewig <st...@innoq.com>
AuthorDate: Sat Nov 26 17:23:20 2022 +0100
warn against multi-byte encoding in tar
---
manual/Tasks/tar.html | 5 ++++-
src/etc/testcases/taskdefs/untar.xml | 8 ++++++++
src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java | 8 ++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
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
@@ -58,6 +58,14 @@
</target>
<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"/>
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
@@ -85,6 +85,14 @@ public class UntarTest {
buildRule.getProject().resolveFile(filename).exists());
}
+ @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");