[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE_3_1_BRANCH: kdelibs/kdecore
From: Andrew Stanley-Jones <asj () cban ! com>
Date: 2003-01-11 23:39:00
[Download RAW message or body]
CVS commit by asj:
This fixes URL tagging a bit:
1. don't match www....blah anymore. Only 1 . is allowed.
2. don't match awww.blah anymore or ahttp://blah. There must not be a letter
or number before the www|http|ftp
3. Parse http://www.blah.com/blah%20blah.html, don't stop highlighting at %.
M +9 -3 kstringhandler.cpp 1.20.2.1
--- kdelibs/kdecore/kstringhandler.cpp #1.20:1.20.2.1
@@ -515,5 +515,5 @@ KStringHandler::perlSplit(const QRegExp
KStringHandler::tagURLs( const QString& text )
{
- /*static*/ QRegExp \
urlEx("(www\\.|(f|ht)tp(|s)://)[\\d\\w\\./,:_~\\?=&;#@\\-\\+]+[\\d\\w/]"); + \
/*static*/ QRegExp urlEx("(www\\.(?!\\.)|(f|ht)tp(|s)://)[\\d\\w\\./,:_~\\?=&;#@\\-\\+\\%]+[\\d\\w/]");
QString richText( text );
@@ -523,7 +523,13 @@ KStringHandler::tagURLs( const QString&
urlLen = urlEx.matchedLength();
QString href = richText.mid( urlPos, urlLen );
- QString anchor( "<a href=\"%1\">%2</a>" );
- anchor = anchor.arg( href ).arg( href );
+ // Qt doesn't support (?<=pattern) so we do it here
+ if((urlPos > 0) && richText[urlPos-1].isLetterOrNumber()){
+ urlPos++;
+ continue;
+ }
+ // Don't use QString::arg since %01, %20, etc could be in the string
+ QString anchor = "<a href=\"" + href + "\">" + href + "</a>";
richText.replace( urlPos, urlLen, anchor );
+
urlPos += anchor.length();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic