Fix encoding detection on platforms with nl_langinfo() (#2030)
libarchive relies on its host program to call setlocale() on platforms with nl_langinfo() present in order to correctly detect the user selected locale. This ensures that bsdunzip does so.
This commit is contained in:
1 parent
d5713db2d4
commit
862984a870
5 files changed
+61
-1
No files matched your search
+3
-1
@@ -1522,7 +1522,8 @@ bsdunzip_test_SOURCES= \
|
||||
unzip/test/test_version.c \
|
||||
unzip/test/test_x.c \
|
||||
unzip/test/test_Z1.c \
|
||||
unzip/test/test_P_encryption.c
|
||||
unzip/test/test_P_encryption.c \
|
||||
unzip/test/test_I.c
|
||||
|
||||
bsdunzip_test_CPPFLAGS= \
|
||||
-I$(top_srcdir)/libarchive -I$(top_srcdir)/libarchive_fe \
|
||||
@@ -1550,4 +1551,5 @@ bsdunzip_test_EXTRA_DIST= \
|
||||
unzip/test/test_encrypted.zip.uu \
|
||||
unzip/test/test_singlefile.zip.uu \
|
||||
unzip/test/test_t_bad.zip.uu \
|
||||
unzip/test/test_I.zip.uu \
|
||||
unzip/test/CMakeLists.txt
|
||||
@@ -57,6 +57,9 @@
|
||||
#ifdef HAVE_FNMATCH_H
|
||||
#include <fnmatch.h>
|
||||
#endif
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
@@ -1210,6 +1213,11 @@ main(int argc, char *argv[])
|
||||
|
||||
lafe_setprogname(*argv, "bsdunzip");
|
||||
|
||||
#if HAVE_SETLOCALE
|
||||
if (setlocale(LC_ALL, "") == NULL)
|
||||
lafe_warnc(0, "Failed to set default locale");
|
||||
#endif
|
||||
|
||||
if (isatty(STDOUT_FILENO))
|
||||
tty = 1;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ IF(ENABLE_UNZIP AND ENABLE_TEST)
|
||||
test_x.c
|
||||
test_Z1.c
|
||||
test_P_encryption.c
|
||||
test_I.c
|
||||
)
|
||||
|
||||
#
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Aaron Lindros
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer
|
||||
* in this position and unchanged.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include "test.h"
|
||||
|
||||
/* Test I arg - file name encoding */
|
||||
DEFINE_TEST(test_I)
|
||||
{
|
||||
const char *reffile = "test_I.zip";
|
||||
int r;
|
||||
|
||||
extract_reference_file(reffile);
|
||||
r = systemf("%s -I UTF-8 %s >test.out 2>test.err", testprog, reffile);
|
||||
assertEqualInt(0, r);
|
||||
assertNonEmptyFile("test.out");
|
||||
assertEmptyFile("test.err");
|
||||
|
||||
assertTextFileContents("Hello, World!\n", "Γειά σου Κόσμε.txt");
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
begin 644 test_I.zip
|
||||
M4$L#!`H```@``&@)AU>$GNBT#@````X````>`!P`SI/.M<ZYSJP@SX/.O\^%
|
||||
M(,Z:SXS/@\Z\SK4N='AT550)``,#8G%E"6)Q975X"P`!!.@#```$Z`,``$AE
|
||||
M;&QO+"!7;W)L9"$*4$L!`AX#"@``"```:`F'5X2>Z+0.````#@```!X`&```
|
||||
M`````````*2!`````,Z3SK7.N<ZL(,^#SK_/A2#.FL^,SX/.O,ZU+G1X=%54
|
||||
L!0`#`V)Q975X"P`!!.@#```$Z`,``%!+!08``````0`!`&0```!F````````
|
||||
`
|
||||
end
|
||||
Reference in new issue
Block a user