]> diplodocus.org Git - nmh/blob - test/mhl/test-rfc6532
Fixed display of header field values with multibyte characters.
[nmh] / test / mhl / test-rfc6532
1 #!/bin/sh
2 ######################################################
3 #
4 # Test compatibility with RFC 6532, Internationalized
5 # Email Headers
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname $0`/../..
13 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "${MH_OBJ_DIR}/test/common.sh"
17
18 setup_test
19 mhl="${MH_LIBEXEC_DIR}/mhl"
20
21 #### Make sure that html-to-text conversion is what we expect.
22 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
23
24
25 start_test 'UTF-8 headers'
26 #### The -- position the multibyte characters to check edge
27 #### cases in the 'UTF-8 headers with narrow width' test below.
28 cat >`mhpath new` <<EOF
29 From: sender--ø@example.com
30 To: recipientæ@example.com
31 To: recipient2@example.com
32 Cc: recip--æ@example.com
33 Subject: Blåbærsyltetøy
34 Date: 20 May 2014 14:28:51 +0200
35 MIME-Version: 1.0
36 Content-Type: text/plain; charset="UTF-8"
37 Content-Transfer-Encoding: 8bit
38
39 Blåbærsyltetøy er veldig godt. Jeg liker blåbærsyltetøy.
40 Jøran.
41
42 Text source:
43 Arnt Gulbrandsen and Jiankang Yao, "Email Address Internationalization",
44 Computing Edge 1:6, June 2015,
45 http://www.computer.org/cms/computing-edge/ce-jun15-final.pdf, p. 50.
46 EOF
47
48 #### Just check that the (UTF-8) headers are displayed unscathed. run_test
49 #### squashes the trailing blank lines from mhl.
50 run_test "$mhl -form mhl.headers `mhpath last`" \
51 'Date: 20 May 2014 14:28:51 +0200
52 To: recipientæ@example.com,
53 recipient2@example.com
54 cc: recip--æ@example.com
55 From: sender--ø@example.com
56 Subject: Blåbærsyltetøy
57
58 MIME-Version: 1.0'
59
60
61 start_test 'UTF-8 headers with narrow width'
62 run_test "$mhl -form mhl.headers -width 18 `mhpath last`" \
63 'Date: 20 May 2
64 ***014 14:28
65 ***:51 +0200
66 To: recipien
67 ***tæ@exampl
68 ***e.com,
69 recipien
70 ***t2@exampl
71 ***e.com
72 cc: recip--æ
73 ***@example.
74 ***com
75 From: sender--
76 ***ø@example
77 ***.com
78 Subject: Blåbærsy
79 ***ltetøy
80
81 MIME-Version: 1.0'
82
83
84 # check with incompatible locale
85 # This is here as a place holder. We should either try to run the (8-bit) text
86 # through iconv, or refuse to display it if the locale is incompatible. In the
87 # case of EAI, that means not UTF-8.
88 # start_test 'incompatible locale'
89 # LC_ALL=C
90 # run_test "$mhl -form mhl.headers `mhpath last`" \
91 # 'Date: 20 May 2014 14:28:51 +0200
92 # To: recipientæ@example.com
93 # From: sender??@example.com
94 # Subject: Bl??b??rsyltet??y
95 #
96 # MIME-Version: 1.0'
97
98
99 finish_test
100 exit $failed