Bug 329875

Summary: KTP doesn’t recognize well URL patterns
Product: [Frameworks and Libraries] telepathy Reporter: ariasuni <aria>
Component: text-uiAssignee: Telepathy Bugs <kde-telepathy-bugs>
Severity: normal CC: hein, kde, mklapetek
Priority: NOR    
Version: 0.7.0   
Target Milestone: 0.8.0   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 0.8.0

Description ariasuni 2014-01-12 13:57:16 UTC
According to RFC 3986, «In practice, URIs are delimited in a variety of ways, but usually within double-quotes "http://example.com/", angle brackets <http://example.com/>» (<http://tools.ietf.org/html/rfc3986#appendix-C>).

When I put "http://example.com" or <http://example.com> in the chat, the created link include the " or >, which break the link (guess how it’s annoying to edit URL each time).

It also put a semicolon if the last character (the first doesn’t matter) is " or >, which is useless, weird, and personally is not what I want, it totally break the flow of my sentence.

Reproducible: Always

Expected Results:  
KTP should:
– Recognize "http://example.com" and <http://example.com>, and they should respectively translate to (HTML): "<a href="http://example.com">http://example.com</a>" and &lt;<a href="http://example.com">http://example.com</a>&gt;.
– never put a semicolon at the end of a link.
Comment 1 Martin Klapetek 2014-01-12 14:41:24 UTC
We're using Konversation's parsing, CC'ing its developer for input.
Comment 2 Eike Hein 2014-01-12 14:43:33 UTC
I don't think you are anymore (Konversation has no problems with the above).
Comment 3 Martin Klapetek 2014-01-12 14:52:30 UTC
Hah, I'm pretty sure we didn't change anything. Maybe it's related to us using a webview for the conversation (and where the links are displayed).

Ok, will investigate.
Comment 4 David Edmundson 2014-02-27 15:42:30 UTC
Right in konvi, wrong here.

Not sure why.
Comment 5 Martin Klapetek 2014-02-27 15:43:39 UTC
Confirming this issue, we can reproduce.
Comment 6 Martin Klapetek 2014-02-27 17:37:05 UTC
Git commit a7df31b729f85cb7381263789010b6bc4aba9e88 by Martin Klapetek.
Committed on 27/02/2014 at 17:36.
Pushed by mklapetek into branch 'master'.

Merge escape and URL filters into one

This is needed to avoid the URL filter detecting wrong link boundaries
as the escape filter would change eg. "<http://kde.org/>" to
&lt;http://kde.org/&gt; and then the URL filter would detect
"http://kde.org/&gt" as the actual link.

Switching the order wouldn't help because the escape filter would escape
the newly inserted <a href...> links and the user would
get &lt;a href.../a&gt; and no clickable links.

Therefore we first detect the links, replace them with placeholders,
then escape everything, then replace placeholders with actual links.

Reviewed-by: David Edmundson
FIXED-IN: 0.8.0

M  +0    -1    KTp/CMakeLists.txt
M  +53   -1    KTp/message-escape-filter.cpp
M  +2    -1    KTp/message-processor.cpp
D  +0    -60   KTp/message-url-filter.cpp