Bug 259039

Summary: Bad encoding in message body when creating mail from command line
Product: kmail2 Reporter: Murz <MurzNN>
Component: composerAssignee: kdepim bugs <kdepim-bugs>
Severity: normal CC: andreas, auxsvr, bugs, kollix, st.gruber
Priority: NOR    
Version: 4.10.0   
Target Milestone: ---   
Platform: Ubuntu Packages   
OS: Linux   
Latest Commit: Version Fixed In: 4.10.1

Description Murz 2010-12-06 20:40:36 UTC
Version:           2.0.89 (using KDE 4.5.80) 
OS:                Linux

When I try to create message with Cyrillic symbols (utf-8 encoding) from command line, 'to' and 'subject' fields filled correctly, but 'body' field have wrong encoding.

If I created this message manually with kmail interface, all works normally.
In other email clients (thunderbird, evolution) all works normally too.

Reproducible: Always

Steps to Reproduce:
Type in command line:
$ kmail 'mailto:Вася <vasya@ya.ru>?subject=Тема&body=Сообщение'

Actual Results:  
To: Вася <vasya@ya.ru>
Subject: Тема

Expected Results:  
To: Вася <vasya@ya.ru>
Subject: Тема

OS: Linux (x86_64) release 2.6.35-23-generic
Compiler: cc
Comment 1 Murz 2011-01-21 09:15:09 UTC
This bug already here on today version from git too.
Comment 2 Murz 2011-05-19 10:46:13 UTC
Bug is still here on current git.
Same problem if I encode the non-ascii symbols to urlencode or quoted-printable.
You can test it via those examples:
$ kmail 'mailto:Вася <vasya@ya.ru>?subject=Тема&body=Сообщение'
$ kmail 'mailto:%D0%92%D0%B0%D1%81%D1%8F%20%3Cvasya@ya.ru%3E?subject=%D0%A2%D0%B5%D0%BC%D0%B0&body=%D0%A1%D0%BE%D0%BE%D0%B1%D1%89%D0%B5%D0%BD%D0%B8%D0%B5'
Comment 3 auxsvr 2011-08-19 16:12:48 UTC
I have this problem if I reply to a message with quotes in non-ascii encoding, including utf-8. One work-around is copy & paste of the quote, then everything appears fine. Also, the set encoding menu does not work at all.
Comment 4 auxsvr 2011-08-19 16:26:10 UTC
Well, I just found out that it was the option "Keep original charset when replying or forwarding (if possible)" that messed up the encoding. The encoding menu still does nothing, though.
Comment 5 Andreas Pietzowski 2011-12-09 13:34:27 UTC
I can confirm this. The following shell command was used:

kmail --composer -s "äöü" --body "äöü"

The composer opens up with subject=äöü and body=äöü

Thanks for fixing. KMail is not usable with scripts at the moment.
Comment 6 Andreas Pietzowski 2012-03-14 21:56:00 UTC
This bug is still present in KDE 4.8.1

"kmail --composer --body äöüß" from command line still just results in crazy characters...
Comment 7 csbugs 2012-03-28 17:46:00 UTC
Well, FWIW:
Initially I thought KMail would simply interpret the CLI input as latin-1 or similar, because "Beste Grüße" became "Beste GrüÃe.
But when I do something like
$> body="$(echo "Beste Grüße"|iconv -f utf8 -t iso8859-1)"
$> echo "$body"
Beste Gr��e
$> kmail --body "$body" somebody@somewhere.tld
I get the following in the mail body:
"Beste Gr��e"

So I can't even work around this bug in scripts - and that *is* bad news.
Comment 8 Murz 2012-08-19 06:00:32 UTC
Confitm that this bug is still exist on kmail2 4.9, body part is bad:
$ kmail 'mailto:Вася <vasya@ya.ru>?subject=Тема&body=Сообщение'
produces body as:
instead of:
Comment 9 csbugs 2012-08-30 12:40:55 UTC
Though my issue is apparently gone (kmail -s "äöü" --body "äöü" seems to work fine now) I can confirm that Murz's example fails.
$ kmail --version
Qt: 4.8.2
KDE Development Platform: 4.9.00 "release 559"
KMail: 4.9
Comment 10 Martin Koller 2013-02-09 20:51:30 UTC
still valid in KDE-4.10
Comment 11 Martin Koller 2013-02-10 10:31:57 UTC
created a patch https://git.reviewboard.kde.org/r/108884/
Comment 12 Martin Koller 2013-02-12 07:28:58 UTC
Git commit 03d53248ab3db31c5680e615f8f1a76e03908b3e by Martin Koller.
Committed on 12/02/2013 at 08:23.
Pushed by mkoller into branch 'KDE/4.10'.

fix character encoding for body in composer window on cmdline usage

assemble message before it is passed to the composer window,
which makes sure that also the ContentType header is used
which contains the charset.
FIXED-IN: 4.10.1
REVIEW: 108884

M  +6    -2    kmail/kmkernel.cpp