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