#!/bin/sh
######################################################
#
# Test filenames
#
######################################################

. "$MH_TEST_COMMON"

require_locale en_US.utf-8 en_US.utf8
LC_ALL=en_US.UTF-8
export LC_ALL

tempdir=`TMPDIR=$MH_TEST_DIR mktemp -d`
cd $tempdir

msgfile=`mhpath b`
cat > $msgfile <<EOF
To: recipient@example.com
From: sender@example.com
Subject: mhlist test
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"

------- =_aaaaaaaaaa0
Content-Type: multipart/related;
    type="multipart/alternative";
    boundary="subpart__1.1"

--subpart__1.1
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="=?UTF-8?B?YmzDpGIudHh0?="

This is the first text/plain part, in a subpart.

--subpart__1.1--

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="=?UTF-8?Q?bl=C3=A4.txt?="
Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
Content-Transfer-Encoding: quoted-printable

This is the second text/plain part.

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="iso-8859-1"; name="test3"
Content-Disposition: attachment;

This is the third text/plain part.

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment; filename="test4"
Content-Transfer-Encoding: base64

VGhpcyBpcyB0aGUgZm91cnRoIHRleHQvcGxhaW4gcGFydC4K

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="iso-8859-1"; name="test23"
Content-Disposition: attachment; filename="test5"

This is the third text/plain part.

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="iso-8859-1"
Content-Disposition: attachment;

This is the third text/plain part.

------- =_aaaaaaaaaa0--
EOF

msgnum=`pick l`

runandcheck "mhstore l" <<!
storing message $msgnum part 1.1 as file bläb.txt
storing message $msgnum part 2 as file blä.txt
storing message $msgnum part 3 as file test3
storing message $msgnum part 4 as file test4
storing message $msgnum part 5 as file test5
storing message $msgnum part 6 as file $msgnum.6.plain
!

cd $OLDPWD
rm -rf $tempdir
