Bug 346370 - KMail does not accept to insert an URL (Copied from Chromium) into a message
Summary: KMail does not accept to insert an URL (Copied from Chromium) into a message
Alias: None
Product: kmail2
Classification: Applications
Component: composereditor-ng (show other bugs)
Version: Git (master)
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Laurent Montel
Depends on:
Blocks: kdepim-15.08
  Show dependency treegraph
Reported: 2015-04-19 18:55 UTC by Raymond Wooninck
Modified: 2015-09-09 08:20 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 15.08.1

Screenshot of kmail when trying to insert an URL (742.68 KB, image/png)
2015-04-23 08:20 UTC, Raymond Wooninck

Note You need to log in before you can comment on or make changes to this bug.
Description Raymond Wooninck 2015-04-19 18:55:37 UTC
The frameworks version of KMail does not insert an url into an email.  When trying to paste an URL, the dialog appears if one wants to add the url into the message, but after selecting this nothing happens.  

Reproducible: Always

Steps to Reproduce:
1. create a new email
2. copy an url from somewhere
3. Paste the url into the email

Actual Results:  
URL is not inserted

Expected Results:  
URL is inserted into the email
Comment 1 Laurent Montel 2015-04-22 12:45:44 UTC

it works fine here.
it's in html mode ?

dnd ?
Comment 2 Raymond Wooninck 2015-04-22 17:48:00 UTC
Hi Laurent, 

I am using ctrl-c and then ctrl-v to paste the url into the message. I get the dialog box asking me if I want to insert the url into the message or to attach it. I select to insert the url into the message and nothing happens. 

The attempts were in a text-only email. Switching on Rich Text, doesn't help.  I looked through the options and now I noticed that if I paste if with Ctrl-Shift-V (Paste without formatting), I can insert the url as it should.  Also the option "Paste as Quotation" works fine.  Just the normal paste doesn't seem to do anything. 

Somehow it looks like that the issue might be with the dialog box which asks me if it should insert the url into the message or as an attachment. I do not get this dialog with the other options and there it works fine. 

What do you mean with dnd ?
Comment 3 Laurent Montel 2015-04-23 05:14:49 UTC
could you provide a screenshot about dialog box please ?
I don't have it.

dnd => drag and drop, you move url from firefox by example with mouse.
(as dnd a file file dolphin for example)
Comment 4 Raymond Wooninck 2015-04-23 08:20:28 UTC
Created attachment 92179 [details]
Screenshot of kmail when trying to insert an URL
Comment 5 Raymond Wooninck 2015-04-23 08:22:55 UTC
Hi Laurent,

I have added a screenshot of the kmail window after I press Ctrl-V.  You can see the two options that are being provided and after selecting the top one, nothing happens.

I tried dnd, but this doesn't do anything. Maybe I am doing something wrong as that dragging the url into Kate also gives an error about a malformed url.  But Ctrl-C, Ctrl-V is working there
Comment 6 Raymond Wooninck 2015-04-23 08:30:26 UTC

I always use Chromium as the web browser and copy & paste doesn't work from here into KMail.  If I take firefox however, then the URL is directly pasted into the message itself and without showing this dialog box. 

I tried pasting the Chromium link into kwrite, kate and vi, to see if there is anything wrong with it, but this seems all correct.
Comment 7 Laurent Montel 2015-04-23 12:20:07 UTC
Indeed kmail + chromium has some problem.
I don't know why yet.
Comment 8 Peter Wu 2015-08-27 15:25:12 UTC
Raymond, what versions are you using? Dragging URLs from Chromium into Konsole seems also broken, but that turns out to be a Qt5 bug: https://bugreports.qt.io/browse/QTBUG-47981
Comment 9 Raymond Wooninck 2015-08-27 18:36:25 UTC
Hi Peter,

I am using Qt 5.5.1 (git snapshots). I can copy an URL from Chromium easily to kate or any other program, except kmail.  As you can see in the bugreport, Laurent was able to reproduce this. I don't think that this particular bug is related to an Qt bug
Comment 10 Gunter Ohrner 2015-08-30 11:15:24 UTC
I just updated from kMail 4.14 to 5.0.0 and experience the same problem with my standard browser Chromium 44.0.2403.89 Ubuntu 15.04 (64-bit).

Neither drag and drop nor copy and paste works for URLs taken from Chromium.
Comment 11 Gunter Ohrner 2015-08-30 11:20:55 UTC
Just to be clear, this is a regression in kMail 5 and worked just fine in kMail 4.x.
Comment 12 Stefan Hamminga 2015-09-07 13:43:54 UTC
Same here with kmail2 5.0.1 and Chrome stable version 45.0.2454.85 (64-bit). Neither the CRTL-v nor the right-click paste option in the message body work.
Comment 13 Kevin Funk 2015-09-08 10:31:29 UTC
After looking through the referenced Qt bug report and through KMail's URL handling code I'm confident to say we should just close this as UPSTREAM bug. Code in KMail looks fine -- when Qt gives us invalid data there's nothing we can do.

Upstream bug: https://bugreports.qt.io/browse/QTBUG-47981

@Laurent, please check.
Comment 14 Kevin Funk 2015-09-08 10:36:06 UTC
Maybe a work-around in KMail would be to just paste QMimeData::text() in case QUrl::toDisplayString on the individual URLs returns an empty string.
Comment 15 Gunter Ohrner 2015-09-08 10:55:48 UTC
(In reply to Kevin Funk from comment #13)
> Upstream bug: https://bugreports.qt.io/browse/QTBUG-47981

This only talks about DnD, while this bug refers to Copy and Paste. Is there the same internal magic behind in Qt in both cases?

(In reply to Kevin Funk from comment #14)
Pasting QMimeData::text() as a last-resort fallback sounds like a robust solution...
Comment 16 Laurent Montel 2015-09-08 12:16:57 UTC
(In reply to Kevin Funk from comment #14)
> Maybe a work-around in KMail would be to just paste QMimeData::text() in
> case QUrl::toDisplayString on the individual URLs returns an empty string.

I will investigate it.
This bug is still on my todo-list :)
Comment 17 Laurent Montel 2015-09-08 19:59:06 UTC
Git commit d00b8d235befd5a41c583e0ed6ae0d7bfe505cae by Montel Laurent.
Committed on 08/09/2015 at 19:57.
Pushed by mlaurent into branch 'Applications/15.08'.

Fix Bug 346370 - KMail does not accept to insert an URL (Copied from Chromium) into a message

FIXED-IN: 15.08.1

It's mainly a workaround against a Qt bug https://bugreports.qt.io/browse/QTBUG-47981

M  +13   -2    kmail/editor/kmcomposewin.cpp

Comment 18 Gunter Ohrner 2015-09-09 08:20:22 UTC
Great, thanks a lot!