1#!/usr/bin/env bash 2 3test_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 8UTF8_YEN=$'\xef\xbf\xa5' 9BIG5_YEN=$'\xa2\x44' 10 11test_require_emacs 12 13# Add four messages with unusual encoding requirements: 14# 15# 1) text/plain in quoted-printable big5 16generate_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 23generate_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 30generate_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 37generate_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 43notmuch new > /dev/null 44 45# Test rendering 46 47test_begin_subtest "Text parts are decoded when rendering" 48test_emacs '(notmuch-show "id:test-plain@example.com") 49 (test-visible-output "OUTPUT.raw")' 50awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT 51cat <<EOF >EXPECTED 52Yen: $UTF8_YEN 53EOF 54test_expect_equal_file EXPECTED OUTPUT 55 56test_begin_subtest "8bit text parts are decoded when rendering" 57test_emacs '(notmuch-show "id:test-plain-8bit@example.com") 58 (test-visible-output "OUTPUT.raw")' 59awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT 60cat <<EOF >EXPECTED 61Yen: $UTF8_YEN 62EOF 63test_expect_equal_file EXPECTED OUTPUT 64 65test_begin_subtest "HTML parts are decoded when rendering" 66test_emacs '(notmuch-show "id:test-html@example.com") 67 (test-visible-output "OUTPUT.raw")' 68awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT 69cat <<EOF >EXPECTED 70[ text/html ] 71Yen: $UTF8_YEN 72EOF 73test_expect_equal_file EXPECTED OUTPUT 74 75# Test saving 76 77test_begin_subtest "Text parts are not decoded when saving" 78rm -f part 79test_emacs '(notmuch-show "id:test-plain@example.com") 80 (search-forward "Yen") 81 (let ((standard-input "\"part\"")) 82 (notmuch-show-save-part))' 83cat <<EOF >EXPECTED 84Yen: $BIG5_YEN 85EOF 86test_expect_equal_file part EXPECTED 87 88test_begin_subtest "8bit text parts are not decoded when saving" 89rm -f part 90test_emacs '(notmuch-show "id:test-plain-8bit@example.com") 91 (search-forward "Yen") 92 (let ((standard-input "\"part\"")) 93 (notmuch-show-save-part))' 94cat <<EOF >EXPECTED 95Yen: $BIG5_YEN 96EOF 97test_expect_equal_file part EXPECTED 98 99test_begin_subtest "HTML parts are not decoded when saving" 100rm -f part 101test_emacs '(notmuch-show "id:test-html@example.com") 102 (search-forward "Yen") 103 (let ((standard-input "\"part\"")) 104 (notmuch-show-save-part))' 105cat <<EOF >EXPECTED 106<html><body>Yen: $BIG5_YEN</body></html> 107EOF 108test_expect_equal_file part EXPECTED 109 110test_begin_subtest "Binary parts are not decoded when saving" 111rm -f part 112test_emacs '(notmuch-show "id:test-binary@example.com") 113 (search-forward "application/") 114 (let ((standard-input "\"part\"")) 115 (notmuch-show-save-part))' 116cat <<EOF >EXPECTED 117Yen: $BIG5_YEN 118EOF 119test_expect_equal_file part EXPECTED 120 121# Test message viewing 122 123test_begin_subtest "Text message are not decoded when viewing" 124test_emacs '(notmuch-show "id:test-plain@example.com") 125 (notmuch-show-view-raw-message) 126 (test-visible-output "OUTPUT.raw")' 127awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT 128cat <<EOF >EXPECTED 129Yen: =A2=44 130EOF 131test_expect_equal_file EXPECTED OUTPUT 132 133test_begin_subtest "8bit text message are not decoded when viewing" 134test_emacs '(notmuch-show "id:test-plain-8bit@example.com") 135 (notmuch-show-view-raw-message) 136 (test-visible-output "OUTPUT.raw")' 137awk 'show {print} /^$/ {show=1}' < OUTPUT.raw > OUTPUT 138cat <<EOF >EXPECTED 139Yen: $BIG5_YEN 140EOF 141test_expect_equal_file EXPECTED OUTPUT 142 143test_done 144