Browse Source

warn against multi-byte encoding in tar

master
Stefan Bodewig 2 years ago
parent
commit
22ef1323cc
3 changed files with 20 additions and 1 deletions
  1. +4
    -1
      manual/Tasks/tar.html
  2. +8
    -0
      src/etc/testcases/taskdefs/untar.xml
  3. +8
    -0
      src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java

+ 4
- 1
manual/Tasks/tar.html View File

@@ -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>


+ 8
- 0
src/etc/testcases/taskdefs/untar.xml View File

@@ -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"/>


+ 8
- 0
src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java View File

@@ -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");


Loading…
Cancel
Save