Bug 366981 - Mailto URL does not allows a body with line breaks
Summary: Mailto URL does not allows a body with line breaks
Status: RESOLVED FIXED
Alias: None
Product: kmail2
Classification: Applications
Component: general (show other bugs)
Version: 5.1.3
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-16 20:30 UTC by Bernhard Lindner
Modified: 2016-08-21 07:39 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.3.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Lindner 2016-08-16 20:30:22 UTC
I expected the following command line should open a mail with a two line body:

kmail "mailto:?to=test@test.com&subject=test&body=line1%0D%0Aline2"

However the line break doesn't work. 

Reproducible: Always

Steps to Reproduce:
1. Open terminal
2. Run kmail "mailto:?to=test@test.com&subject=test&body=line1%0D%0Aline2"
3. Check if the expected line break is missing

Actual Results:  
No line break between line1 and line2

Expected Results:  
Line break between line1 and line2

Kubuntu 16.04.
Comment 1 Bernhard Lindner 2016-08-16 21:08:51 UTC
An different users reported that the command line works with KMail 4.14.2.
Comment 2 Nicolás Alvarez 2016-08-16 22:21:20 UTC
My apologies, I accidentally selected this bug while deleting a lot of spam. Restoring data...
Comment 3 Bernhard Scheirle 2016-08-18 06:36:19 UTC
I'm also affected by this bug.

I think I found the cause for this, and if so it should be easy to fix.

KMail uses MessageCore::StringUtil::parseMailtoUrl[1] to parse url query parameters.
In parseMailtoUrl it uses QUrlQuery::queryItems() to get the list of parameters.
By default queryItems does not decode all "%" elements.[2]

So using QUrlQuery::queryItems(QUrl::FullyDecoded) instead should fix this.

I think the explicit "%0A" to "\n" transformation in Lines 197-202 would than be obsolete as well. [1]
Especially since mailto urls must have "%0D%0A" and not "%0A" line breaks.  [3]

[1] Line 185: https://quickgit.kde.org/?p=messagelib.git&a=blob&h=41d01b75b9058281ac9f5bdd4e4abea0c34b309a&hb=0c5e64ed193141edd63de7eb01a10e6d353e1856&f=messagecore%2Fsrc%2Futils%2Fstringutil.cpp
[2] http://doc.qt.io/qt-5/qurl.html#ComponentFormattingOption-enum
[3] RFC2368 Section 5: http://www.ietf.org/rfc/rfc2368.txt
Comment 4 Laurent Montel 2016-08-21 07:20:46 UTC
Git commit c5cd3c5129a1b8a33da894eaadb79b461e45c3cc by Montel Laurent.
Committed on 21/08/2016 at 07:20.
Pushed by mlaurent into branch 'Applications/16.08'.

Fix Bug 366981 - Mailto URL does not allows a body with line breaks

FIXED-IN: 5.3.1

M  +11   -0    messagecore/autotests/stringutiltest.cpp
M  +1    -0    messagecore/autotests/stringutiltest.h
M  +1    -3    messagecore/src/utils/stringutil.cpp

http://commits.kde.org/messagelib/c5cd3c5129a1b8a33da894eaadb79b461e45c3cc
Comment 5 Bernhard Scheirle 2016-08-21 07:39:43 UTC
Thanks Montel.

But the `if (!body.isEmpty()) { [...] }` does now nothing: body comes from values and gets inserted into values (with the same key).