]> granicus.if.org Git - curl/commitdiff
tests: use consistent environment variables for setting charset
authorDan Fandrich <dan@coneharvesters.com>
Thu, 23 Feb 2017 20:47:17 +0000 (21:47 +0100)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 25 Feb 2017 14:33:29 +0000 (15:33 +0100)
The character set in POSIX is set by the locale defined by (in
decreasing order of precedence) the LC_ALL, LC_CTYPE and LANG
environment variables (CHARSET was used by libidn but not libidn2).
LC_ALL is cleared to ensure that LC_CTYPE takes effect, but LC_ALL is
not used to set the locale to ensure that other parts of the locale
aren't overridden.  Since there doesn't seem to be a cross-platform way
of specifying a UTF-8 locale, and not all systems may support UTF-8, a
<precheck> is used to skip the test if UTF-8 can't be verified to be
available.  Test 1035 was also converted to UTF-8 for consistency, as
the actual character set used there is irrelevant to the test.

This patch uses a different UTF-8 locale than the last attempt, namely
en_US.UTF-8. This one has been verified on 7 different Linux and BSD
distributions and is more complete and usable than the locale UTF-8 (on
at least some systems).

tests/data/test1034
tests/data/test1035
tests/data/test165
tests/data/test2046
tests/data/test2047

index c47574051328a2808fb1195be45342da2a97364b..063f52b322b34eb1240eef4ee2fb677b5f3450c8 100644 (file)
@@ -32,8 +32,12 @@ http
 idn
 </features>
 <setenv>
-CHARSET=UTF-8
+LC_ALL=
+LC_CTYPE=en_US.UTF-8
 </setenv>
+<precheck>
+perl -MI18N::Langinfo=langinfo,CODESET -e 'die "Needs a UTF-8 locale" if (lc(langinfo(CODESET())) ne "utf-8");'
+</precheck>
  <name>
 HTTP over proxy with malformatted IDN host name
  </name>
index 05172ec9a0421143d2509dbf3eabc2e13eafd67c..033a48a7228e7108f1eb2484e6e204ede662a564 100644 (file)
@@ -32,14 +32,17 @@ http
 idn
 </features>
 <setenv>
-CHARSET=UTF-8
-LANG=en_US.UTF-8
+LC_ALL=
+LC_CTYPE=en_US.UTF-8
 </setenv>
+<precheck>
+perl -MI18N::Langinfo=langinfo,CODESET -e 'die "Needs a UTF-8 locale" if (lc(langinfo(CODESET())) ne "utf-8");'
+</precheck>
  <name>
 HTTP over proxy with too long IDN host name
  </name>
  <command>
-http://too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local/page/1035 -x %HOSTIP:%HTTPPORT
+http://too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local/page/1035 -x %HOSTIP:%HTTPPORT
 </command>
 </client>
 
@@ -50,8 +53,8 @@ http://too-long-IDN-name-c
 ^User-Agent:.*
 </strip>
 <protocol>
-GET http://too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local/page/1035 HTTP/1.1\r
-Host: too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local\r
+GET http://too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local/page/1035 HTTP/1.1\r
+Host: too-long-IDN-name-cürl-rüles-la-la-la-dee-da-flooby-nooby.local\r
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 \r
index 6fc0ad2d572dcbf80a5018e5204b878296870170..b9a1ed78690acec23d263d9fbb40961f6245c913 100644 (file)
@@ -31,9 +31,12 @@ http
 idn
 </features>
 <setenv>
-CHARSET=UTF-8
-LANG=en_US.UTF-8
+LC_ALL=
+LC_CTYPE=en_US.UTF-8
 </setenv>
+<precheck>
+perl -MI18N::Langinfo=langinfo,CODESET -e 'die "Needs a UTF-8 locale" if (lc(langinfo(CODESET())) ne "utf-8");'
+</precheck>
  <name>
 HTTP over proxy with IDN host name
  </name>
index 0f0eb52c672c581ee4aa5607032edb217f2aedcb..dcd202f04418a8d900955a418059590f34d330e3 100644 (file)
@@ -41,9 +41,12 @@ http
 idn
 </features>
 <setenv>
-CHARSET=UTF-8
-LANG=en_US.UTF-8
+LC_ALL=
+LC_CTYPE=en_US.UTF-8
 </setenv>
+<precheck>
+perl -MI18N::Langinfo=langinfo,CODESET -e 'die "Needs a UTF-8 locale" if (lc(langinfo(CODESET())) ne "utf-8");'
+</precheck>
  <name>
 Connection re-use with IDN host name
  </name>
index f54a30af658ea54642e49ee10de4f3308b214d47..fc140486bc4e937cada5d9f557e7876552e33b57 100644 (file)
@@ -42,9 +42,12 @@ http
 idn
 </features>
 <setenv>
-CHARSET=UTF-8
-LANG=en_US.UTF-8
+LC_ALL=
+LC_CTYPE=en_US.UTF-8
 </setenv>
+<precheck>
+perl -MI18N::Langinfo=langinfo,CODESET -e 'die "Needs a UTF-8 locale" if (lc(langinfo(CODESET())) ne "utf-8");'
+</precheck>
  <name>
 Connection re-use with IDN host name over HTTP proxy
  </name>