From kde-commits Fri Aug 01 21:34:53 2003 From: Olivier Goffart Date: Fri, 01 Aug 2003 21:34:53 +0000 To: kde-commits Subject: kdenonbeta/kopete/libkopete X-MARC-Message: https://marc.info/?l=kde-commits&m=105977371010147 CVS commit by ogoffart: Some fix in the url parsing -fix when the url ends with two spaces (the   was interpreted) -fix adress like http://www.xyz.com/~www.xxx.y where the second www was interpreted too -add tool-tip PLEASE TEST URL M +6 -5 kopetemessage.cpp 1.119 --- kdenonbeta/kopete/libkopete/kopetemessage.cpp #1.118:1.119 @@ -480,11 +480,10 @@ QString KopeteMessage::parseLinks( const //Replace http/https/ftp links - result.replace( QRegExp( QString::fromLatin1("\\b((http(s?)://\\w|ftp://\\w)[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)\\b") ), QString::fromLatin1("\\1" ) ); - result.replace( QRegExp( QString::fromLatin1("^(www\\.[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)\\b") ), QString::fromLatin1("\\1" ) ); - result.replace( QRegExp( QString::fromLatin1("([^/])\\b(www\\.[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)\\b") ), QString::fromLatin1("\\1\\2" ) ); - + result.replace( QRegExp( QString::fromLatin1("(?:\\b| )((?:http(?:s?)://\\w|ftp://\\w)[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)(?:\\b| )") ), QString::fromLatin1("\\1" ) ); + result.replace( QRegExp( QString::fromLatin1("^(www\\.[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)(?:\\b| )") ), QString::fromLatin1("\\1" ) ); + result.replace( QRegExp( QString::fromLatin1("([^/.;,?#=\\-%~])\\b(www\\.[-\\w\\._]+[-\\w\\./#&;:=\\?~%_,]*)(?:\\b| )") ), QString::fromLatin1("\\1\\2" ) ); //Replace Email Links - result.replace( QRegExp( QString::fromLatin1("\\b([\\w-_\\.]+@([-_\\w\\.]+\\.\\w+)+)\\b") ), QString::fromLatin1("\\1") ); + result.replace( QRegExp( QString::fromLatin1("(?:\\b| )([\\w\\-_\\.]+@(?:[-_\\w\\.]+\\.\\w+)+)(?:\\b| )") ), QString::fromLatin1("\\1") ); return result;