From: <er...@us...> - 2006-08-28 12:07:11
|
Author: erijo Date: Mon Aug 28 13:51:41 2006 New Revision: 4585 URL: http://svn.licq.org/viewvc/licq?rev=3D4585&view=3Drev Log: * Can't use %1 and %2 together with QString::arg() when constructing the url since it breaks down when the url itself contains %##. * Use \w instead of a-z0-9 in regexp. This way we allow non ascii chars in the url. Closes #1375. Modified: trunk/qt-gui/src/mlview.cpp Modified: trunk/qt-gui/src/mlview.cpp URL: http://svn.licq.org/viewvc/licq/trunk/qt-gui/src/mlview.cpp?rev=3D4585= &r1=3D4584&r2=3D4585&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- trunk/qt-gui/src/mlview.cpp (original) +++ trunk/qt-gui/src/mlview.cpp Mon Aug 28 13:51:41 2006 @@ -87,7 +87,7 @@ "(?:(https?|ftp)://(.+(:.+)?@)?|www\\d?\\.)" // protocoll://[user[:= password]@] or www[digit]. "[a-z0-9.-]+\\.([a-z]+|[0-9]+)" // hostname.tld or ip = address "(:[0-9]+)?" // optional port - "(/([-a-z0-9%{}|\\\\^~`;/?:@=3D&$_.+!*'(),#]|\\[|\\])*)?"); + "(/([-\\w%{}|\\\\^~`;/?:@=3D&$_.+!*'(),#]|\\[|\\])*)?"); reURL.setMinimal(false); reURL.setCaseSensitive(false); =20 @@ -114,7 +114,12 @@ { const QString url =3D reURL.cap(); const QString fullurl =3D (reURL.cap(1).isEmpty() ? QString("http:= //%1").arg(url) : url); - const QString link =3D QString("<a href=3D\"%1\">%2</a>").arg(full= url).arg(url); + + // Can't use QString("<a href=3D\"%1\">%2</a>").arg(fullurl).arg(u= rl) since it breaks + // down when fullurl contains urlencoded chars (%##). + const QString link =3D QString::fromLatin1("<a href=3D\"") + fullu= rl + QString::fromLatin1("\">") + + url + QString::fromLatin1("</a>"); + text.replace(urlPos, reURL.matchedLength(), link); pos =3D urlPos + link.length(); } @@ -122,7 +127,8 @@ { const QString mail =3D reMail.cap(); const QString fullmail =3D (reMail.cap(1).isEmpty() ? QString("mai= lto:%1").arg(mail) : mail); - const QString link =3D QString("<a href=3D\"%1\">%2</a>").arg(full= mail).arg(mail); + const QString link =3D QString::fromLatin1("<a href=3D\"") + fullm= ail + QString::fromLatin1("\">") + + mail + QString::fromLatin1("</a>"); text.replace(mailPos, reMail.matchedLength(), link); pos =3D mailPos + link.length(); } |