ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# Example attachment decoder script. The attachment comes from stdin, and
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# the script is expected to output UTF-8 data to stdout. (If the output isn't
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# UTF-8, everything except valid UTF-8 sequences are dropped from it.)
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# The attachment decoding is enabled by setting:
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# fts_decoder = decode2text
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# service decode2text {
2f971d239f217826f6eae8b16ef74ed1420209dfTimo Sirainen# executable = script /usr/local/libexec/dovecot/decode2text.sh
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# user = dovecot
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# unix_listener decode2text {
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# The second parameter is the format's filename extension, which is used when
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# found from a filename of application/octet-stream. You can also add more
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# extensions by giving more parameters.
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenapplication/vnd.openxmlformats-officedocument.wordprocessingml.document docx
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenapplication/vnd.openxmlformats-officedocument.presentationml.presentation pptx
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenapplication/vnd.oasis.opendocument.spreadsheet ods
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenapplication/vnd.oasis.opendocument.presentation odp
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenfmt=`echo "$formats" | grep -w "^$content_type" | cut -d ' ' -f 2`
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen echo "Content-Type: $content_type not supported" >&2
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# most decoders can't handle stdin directly, so write the attachment
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen# to a temp file
c46d921c475c1f99d12c5e469a6f6862d25a5bb8Timo Sirainen trap "kill -9 $childpid; rm -f $path" 1 2 3 14 15
c4ba1974c6ef3c9725b26c155c14ed9e47d21518Timo Sirainenelif [ $fmt = "odt" -o $fmt = "ods" -o $fmt = "odp" ]; then
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen echo "Buggy decoder script: $fmt not handled" >&2