[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:17 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=fb33764

The following commit has been merged in the master branch:
commit fb33764f3cb678be1364b97e2f3a00f646fa9d8e
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Wed Apr 27 11:17:37 2011 +0200

    Better link detection for bug 270345
    
    REVIEW: david edmundson
---
 lib/adium-theme-view.cpp | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index 8a8818c..2211cfa 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -362,24 +362,40 @@ QString AdiumThemeView::replaceMessageKeywords(QString &htmlTemplate, const Adiu
     htmlTemplate.replace("%message%", m_emoticons.theme().parseEmoticons(info.message()));
 
     // link detection
-    QRegExp linkRegExp("(smb://|s{0,1}ftp://|www.|https{0,1}://)[^ 	



]+");
+    QRegExp linkRegExp("\b(smb://|s{0,1}ftp://|www\.|https{0,1}://)\b[^ 	



]+");
     int index = 0;
-    while((index = linkRegExp.indexIn(htmlTemplate, index)) != -1) {
+
+    while ((index = linkRegExp.indexIn(htmlTemplate, index)) != -1) {
         QString realUrl = linkRegExp.cap(0);
 
-        // remove line breaks
-        realUrl.remove("<br/>");
+        // text not wanted in a link ( <,> )
+        QRegExp unwanted("(<|>)");
 
-        if (realUrl.startsWith("www")) {
-            realUrl.prepend("http://");
-        }
+        if (!realUrl.contains(unwanted)) {
+            // string to show to user
+            QString shownUrl = realUrl;
+
+            // check for newline and cut link when found
+            if (realUrl.contains("<br/>")) {
+                int findIndex = realUrl.indexOf("<br/>");
+                realUrl.truncate(findIndex);
+                shownUrl.truncate(findIndex);
+            }
 
-        // if the url is changed, show in chat what the user typed in
-        QString link = "<a href='" + realUrl + "'>" + linkRegExp.cap(0) + "</a>";
-        htmlTemplate.replace(index, linkRegExp.cap(0).length(), link);
+            // check prefix
+            if (realUrl.startsWith("www")) {
+                realUrl.prepend("http://");
+            }
 
-        // advance pos otherwise i end up parsing same link
-        index += link.length();
+            // if the url is changed, show in chat what the user typed in
+            QString link = "<a href='" + realUrl + "'>" + shownUrl + "</a>";
+            htmlTemplate.replace(index, shownUrl.length(), link);
+
+            // advance position otherwise I end up parsing the same link
+            index += link.length();
+        } else {
+            index += realUrl.length();
+        }
     }
 
     //service

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list