From 86edf6267024d548c8e074adfc7bc5ceeb453e41 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Fri, 13 Nov 2009 13:19:48 +0100 Subject: [PATCH] Recognize @mention links for Twitter lists Signed-off-by: Stephan Beyer Signed-off-by: Dominik Kapusta --- twitterapi/xmlparser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/twitterapi/xmlparser.cpp b/twitterapi/xmlparser.cpp index f2ff378..70a11f2 100644 --- a/twitterapi/xmlparser.cpp +++ b/twitterapi/xmlparser.cpp @@ -279,8 +279,12 @@ QString XmlParser::textToHtml( QString newText ) QRegExp ahref( "((https?|ftp)://[^ ]+)( ?)", Qt::CaseInsensitive ); newText.replace( ahref, "\\1\\3" ); - // recognize @mentions (letters, numbers and _ are allowed in nicks) - newText.replace( QRegExp( "(^| |[^a-zA-Z0-9])@([\\w\\d_]+)" ), + // recognize @mentions (letters, numbers are allowed in nicks) + // for Twitter, also allow _ in nicks and @user/list; + // the list name can only contain letters, numbers and dashes (-) + newText.replace( m_serviceUrl == TwitterAPI::URL_TWITTER ? + QRegExp( "(^|[^a-zA-Z0-9])@([\\w\\d_]+(/[\\w\\d-]+)?)" ) : + QRegExp( "(^|[^a-zA-Z0-9])@([\\w\\d]+)" ), QString( "\\1@\\2").arg( networkUrl ) ); // recognize e-mail addresses