Bug 113177 - [patch] Trim whitespace/linebreaks in wrapped (long) URLs when using context menu "Open ..."-action
Summary: [patch] Trim whitespace/linebreaks in wrapped (long) URLs when using context ...
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-24 00:51 UTC by Daniel Hahler
Modified: 2008-09-30 09:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
testcase (68 bytes, text/html)
2007-01-07 13:03 UTC, Philip Rodrigues
Details
patch to fix (594 bytes, patch)
2007-01-07 13:04 UTC, Philip Rodrigues
Details
patch (415 bytes, patch)
2008-09-30 09:25 UTC, Andrea Iacovitti
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Hahler 2005-09-24 00:51:36 UTC
Version:           3.4.91 (using KDE KDE 3.4.90)
Installed from:    Unlisted Binary Package

A great feature of Konqueror is to select a non-linked (without html anchor tag) URL on a website, right-click and choose "Open 'http://.....'".

Unfortunately this fails on wrapped lines, where there are line breaks (and spaces) in between the link.

It is related to a bug that is marked as FIXED (http://bugs.kde.org/show_bug.cgi?id=82325), but at least is reproducable with Konqueror 3.4.91 (again?).

I suggest removing any leading and trailing, _plus_ whitespace around line breaks that are in the selection.
Comment 1 Daniel Hahler 2005-09-24 00:52:31 UTC
This is with Kubuntu's KDE 3.5beta 1.
Comment 2 Philip Rodrigues 2007-01-07 13:03:25 UTC
Confirmed on r620k. Patch and testcase to be attached.
Comment 3 Philip Rodrigues 2007-01-07 13:03:58 UTC
Created attachment 19151 [details]
testcase
Comment 4 Philip Rodrigues 2007-01-07 13:04:57 UTC
Created attachment 19152 [details]
patch to fix

Patch to be applied in kdelibs/khtml
Comment 5 Daniel Hahler 2007-04-16 23:12:16 UTC
There are more testcases in Bug 134190 (dupe).

It would be great, if the patch would get tested against those testcases as well and then committed for 3.5.7!
Comment 6 Michael Pyne 2007-06-05 01:56:04 UTC
I would recommend

+    url.replace(QRegExp("[\\s]*\\n+[\\s]*"),"");

instead of

+    url.replace(QRegExp("[\\ ]*\\n+[\\ ]*"),"");

notice that the space is replaced by a s. (\s represents whitespace of all types in regular expressions).  Otherwise I'm not sure why you need the backslashes in the square-bracketed expressions.

Also please try to follow the style of the rest of the code.  The url=m_part->... line should have spaces around the equal sign for instance.  Other than that I think it's fine.
Comment 7 FiNeX 2008-05-05 14:24:13 UTC
It should be applied even on Konqueror 4.
Comment 8 David Faure 2008-07-01 21:55:01 UTC
SVN commit 826895 by dfaure:

Fix handling of selected text in context menu actions:
 * "search in <search provider>" should ignore leading/trailing whitespace, as well as the &nbsp; special char
 * "open <url>" (when the selected text looks like a URL) should also ignore linefeeds, i.e. treat the selection as a single line.
BUG: 113177


 M  +36 -21    khtml_ext.cpp  
 M  +3 -1      khtml_ext.h  
 M  +15 -4     khtml_part.cpp  
 M  +12 -3     khtml_part.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=826895
Comment 9 Andrea Iacovitti 2008-09-30 09:25:16 UTC
Created attachment 27615 [details]
patch

A very useful future is to offer "Open url" even for selected text starting with "www.". Patch attached .