]> git.cworth.org Git - notmuch/blob - test/T455-emacs-charsets.sh
debian: bump compat level to 11
[notmuch] / test / T455-emacs-charsets.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs notmuch-show charset handling"
4 . $(dirname "$0")/test-lib.sh || exit 1
5
6
7 UTF8_YEN=$'\xef\xbf\xa5'
8 BIG5_YEN=$'\xa2\x44'
9
10 # Add four messages with unusual encoding requirements:
11 #
12 # 1) text/plain in quoted-printable big5
13 generate_message \
14     [id]=test-plain@example.com \
15     '[content-type]="text/plain; charset=big5"' \
16     '[content-transfer-encoding]=quoted-printable' \
17     '[body]="Yen: =A2=44"'
18
19 # 2) text/plain in 8bit big5
20 generate_message \
21     [id]=test-plain-8bit@example.com \
22     '[content-type]="text/plain; charset=big5"' \
23     '[content-transfer-encoding]=8bit' \
24     '[body]="Yen: '$BIG5_YEN'"'
25
26 # 3) text/html in quoted-printable big5
27 generate_message \
28     [id]=test-html@example.com \
29     '[content-type]="text/html; charset=big5"' \
30     '[content-transfer-encoding]=quoted-printable' \
31     '[body]="<html><body>Yen: =A2=44</body></html>"'
32
33 # 4) application/octet-stream in quoted-printable of big5 text
34 generate_message \
35     [id]=test-binary@example.com \
36     '[content-type]="application/octet-stream"' \
37     '[content-transfer-encoding]=quoted-printable' \
38     '[body]="Yen: =A2=44"'
39
40 notmuch new > /dev/null
41
42 # Test rendering
43
44 test_begin_subtest "Text parts are decoded when rendering"
45 test_emacs '(notmuch-show "id:test-plain@example.com")
46             (test-visible-output "OUTPUT.raw")'
47 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
48 cat <<EOF >EXPECTED
49 Yen: $UTF8_YEN
50 EOF
51 test_expect_equal_file EXPECTED OUTPUT
52
53 test_begin_subtest "8bit text parts are decoded when rendering"
54 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
55             (test-visible-output "OUTPUT.raw")'
56 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
57 cat <<EOF >EXPECTED
58 Yen: $UTF8_YEN
59 EOF
60 test_expect_equal_file EXPECTED OUTPUT
61
62 test_begin_subtest "HTML parts are decoded when rendering"
63 test_emacs '(notmuch-show "id:test-html@example.com")
64             (test-visible-output "OUTPUT.raw")'
65 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
66 cat <<EOF >EXPECTED
67 [ text/html ]
68 Yen: $UTF8_YEN
69 EOF
70 test_expect_equal_file EXPECTED OUTPUT
71
72 # Test saving
73
74 test_begin_subtest "Text parts are not decoded when saving"
75 rm -f part
76 test_emacs '(notmuch-show "id:test-plain@example.com")
77             (search-forward "Yen")
78             (let ((standard-input "\"part\""))
79                (notmuch-show-save-part))'
80 cat <<EOF >EXPECTED
81 Yen: $BIG5_YEN
82 EOF
83 test_expect_equal_file part EXPECTED
84
85 test_begin_subtest "8bit text parts are not decoded when saving"
86 rm -f part
87 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
88             (search-forward "Yen")
89             (let ((standard-input "\"part\""))
90                (notmuch-show-save-part))'
91 cat <<EOF >EXPECTED
92 Yen: $BIG5_YEN
93 EOF
94 test_expect_equal_file part EXPECTED
95
96 test_begin_subtest "HTML parts are not decoded when saving"
97 rm -f part
98 test_emacs '(notmuch-show "id:test-html@example.com")
99             (search-forward "Yen")
100             (let ((standard-input "\"part\""))
101                (notmuch-show-save-part))'
102 cat <<EOF >EXPECTED
103 <html><body>Yen: $BIG5_YEN</body></html>
104 EOF
105 test_expect_equal_file part EXPECTED
106
107 test_begin_subtest "Binary parts are not decoded when saving"
108 rm -f part
109 test_emacs '(notmuch-show "id:test-binary@example.com")
110             (search-forward "application/")
111             (let ((standard-input "\"part\""))
112                (notmuch-show-save-part))'
113 cat <<EOF >EXPECTED
114 Yen: $BIG5_YEN
115 EOF
116 test_expect_equal_file part EXPECTED
117
118 # Test message viewing
119
120 test_begin_subtest "Text message are not decoded when viewing"
121 test_emacs '(notmuch-show "id:test-plain@example.com")
122             (notmuch-show-view-raw-message)
123             (test-visible-output "OUTPUT.raw")'
124 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
125 cat <<EOF >EXPECTED
126 Yen: =A2=44
127 EOF
128 test_expect_equal_file EXPECTED OUTPUT
129
130 test_begin_subtest "8bit text message are not decoded when viewing"
131 test_emacs '(notmuch-show "id:test-plain-8bit@example.com")
132             (notmuch-show-view-raw-message)
133             (test-visible-output "OUTPUT.raw")'
134 awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT
135 cat <<EOF >EXPECTED
136 Yen: $BIG5_YEN
137 EOF
138 test_expect_equal_file EXPECTED OUTPUT
139
140 test_done