Bug 255070 - KUrl::populateMimeData does not escape URL copies into QMimeData
Summary: KUrl::populateMimeData does not escape URL copies into QMimeData
Status: RESOLVED WORKSFORME
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 0.1
Platform: Gentoo Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-23 23:28 UTC by Matt Whitlock
Modified: 2018-11-07 08:43 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Whitlock 2010-10-23 23:28:13 UTC
Version:           4.5.2 (using KDE 4.5.2) 
OS:                Linux

The "Copy Link Address" item on the context menu for a hyperlink copies an unescaped URL to the clipboard. When subsequently pasted elsewhere (e.g., KMail composer, web forum post) the URL may not be auto-linked completely because it may contain illegal characters (such as spaces).

Worse, if parts within the URL contain characters that have special meaning in the context of parsing a URL, the URL will take on different (unintended) semantics when re-parsed. For example, if the path part contains a question mark, decoding the URL and then re-encoding it will cause that question mark to be interpreted as a delimiter between the path part and the query string part rather than as internal to the path part.

Reproducible: Didn't try

Steps to Reproduce:
Find a web page containing a hyperlink to a URL that contains special characters such as spaces.  Right-click the hyperlink and choose "Copy Link Address".  Paste into a text field widget in any application.

Actual Results:  
The pasted URL contains unescaped special characters, which will confuse auto-linkers and may even change the meaning of the URL.

Expected Results:  
The pasted URL should be properly escaped using percent-encoding, as specified by IETF RFC 3986 section 2.1.

According to IETF RFC 3986 section 2.4: "Once produced, a URI is always in its percent-encoded form."  So technically, it is also wrong for Konqueror to display the unencoded URL in the address bar.
Comment 1 Dawit Alemayehu 2011-06-09 21:21:23 UTC
Please provide a valid test case. Simply saying "find a web page containing a hyperlink to a URL..." will not work because it makes the report a hypothetical.
Comment 2 Matt Whitlock 2011-06-10 00:05:22 UTC
(In reply to comment #1)
> Please provide a valid test case. Simply saying "find a web page containing a
> hyperlink to a URL..." will not work because it makes the report a
> hypothetical.

Test case with step-by-step instructions:
http://www.mattwhitlock.com/bug255070.html
Comment 3 Dawit Alemayehu 2011-06-10 03:28:48 UTC
Git commit bcc11e760500fac6f05d016bc23977de7a4d2bbe by Dawit Alemayehu.
Committed on 10/06/2011 at 03:12.
Pushed by adawit into branch '1.2'.

- Use QWebPage's built-in actions to copy link url so that URL are properly encoded.
- Make sure the URL we copy from a media element, which is not supported by a
  QWebPage action, is properly precent encoded.

CCBUG: 255070

M  +3    -14   src/kwebkitpart_ext.cpp     

http://commits.kde.org/kwebkitpart/bcc11e760500fac6f05d016bc23977de7a4d2bbe
Comment 4 Dawit Alemayehu 2011-06-10 03:32:03 UTC
Git commit 09f33d88cda4908ed6b11e31ce40bb9f8c58f99b by Dawit Alemayehu.
Committed on 10/06/2011 at 03:12.
Pushed by adawit into branch 'master'.

- Use QWebPage's built-in actions to copy link url so that URL are properly encoded.
- Make sure the URL we copy from a media element, which is not supported by a
  QWebPage action, is properly precent encoded.

CCBUG: 255070
(cherry picked from commit bcc11e760500fac6f05d016bc23977de7a4d2bbe)

M  +3    -14   src/kwebkitpart_ext.cpp     

http://commits.kde.org/kwebkitpart/09f33d88cda4908ed6b11e31ce40bb9f8c58f99b
Comment 5 Dawit Alemayehu 2011-06-10 03:39:32 UTC
I have fixed the issue in kwebkitpart by using QtWebKit's built-in actions instead of doing the copying manually. The fix for khtml requires that KUrl, more specifically KUrl::populateMimeData gets fixed, so I am changing the title of this bug report and reassigning this to kdelibs.
Comment 6 Matt Whitlock 2011-06-10 04:29:57 UTC
(In reply to comment #5)
> I have fixed the issue in kwebkitpart by using QtWebKit's built-in actions
> instead of doing the copying manually.

Excellent.  I almost always use kwebkitpart.  The only time I don't is when Konqueror disrespects my embedding services preference order.
Comment 7 Andrew Crouthamel 2018-11-06 15:15:44 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Matt Whitlock 2018-11-06 16:33:14 UTC
I stopped using Konqueror a long time ago because it wasn't keeping up with Chromium. I no longer keep it installed, so I have no stake in this bug report anymore. Feel free to close, as there are no other commenters reporting the same issue.
Comment 9 Andrew Crouthamel 2018-11-07 08:43:29 UTC
Thanks for the update!