X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Fclickable.cpp;h=df2d3dc44e8515e4aa689b0fb19fe21c02ccfb12;hp=dcda95f16717bb89fbcb8e397f13816a1be43b12;hb=2c64480b5c036a4703fa25a3761d2814d81a6b28;hpb=c0ce60dfa3a39d3c29f9208eb0ae122513f8aeb1 diff --git a/src/uisupport/clickable.cpp b/src/uisupport/clickable.cpp index dcda95f1..df2d3dc4 100644 --- a/src/uisupport/clickable.cpp +++ b/src/uisupport/clickable.cpp @@ -50,13 +50,15 @@ void Clickable::activate(NetworkId networkId, const QString &text) const { // (RegExps are not constant while matching, and they are static here for efficiency) ClickableList ClickableList::fromString(const QString &str) { // For matching URLs + static QString scheme("(?:(?:mailto:|(?:[+.-]?\\w)+://)|www(?=\\.\\S+\\.))"); + static QString authority("(?:[,.;@:-]?\\w+)+(?::\\d+)?"); + static QString urlChars("(?:[,.;:\\w~@/?&=+$()!%#*{}\\[\\]'^-])"); static QString urlEnd("(?:>|[,.;:\"]*\\s|\\b|$)"); - static QString urlChars("(?:[,.;:]*[\\w\\-~@/?&=+$()!%#*|{}\\[\\]'^])"); static QRegExp regExp[] = { // URL // QRegExp(QString("((?:https?://|s?ftp://|irc://|mailto:|www\\.)%1+|%1+\\.[a-z]{2,4}(?:?=/%1+|\\b))%2").arg(urlChars, urlEnd)), - QRegExp(QString("\\b((?:(?:mailto:|\\w+://)|www\\.)%1+)%2").arg(urlChars, urlEnd), Qt::CaseInsensitive), + QRegExp(QString("\\b(%1%2(?:/%3*)?)%4").arg(scheme, authority, urlChars, urlEnd), Qt::CaseInsensitive), // Channel name // We don't match for channel names starting with + or &, because that gives us a lot of false positives.