mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kurifilter-plugins: fix matching of mail links
it was broken before the fork and sill is far from perfect due to the pattern being limited to fully qualified mail links but then again - is foo@bar.com link to mail without the "mailto:" or link to website with user? Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5b7845d814
commit
19f926d669
1 changed files with 25 additions and 1 deletions
|
@ -118,6 +118,13 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const
|
|||
KUrl url = data.uri();
|
||||
QString cmd = data.typedString();
|
||||
|
||||
/*
|
||||
* Extra match to be performed on the path for mailto:foo@bar.baz, the
|
||||
* pattern for it requires fully qualified mail link (without the scheme) but
|
||||
* the URL includes the scheme
|
||||
*/
|
||||
QString cmd2 = url.path();
|
||||
|
||||
// WORKAROUND: Allow the use of '@' in the username component of a URL since
|
||||
// other browsers such as firefox in their infinite wisdom allow such blatant
|
||||
// violations of RFC 3986. BR# 69326/118413.
|
||||
|
@ -416,7 +423,7 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const
|
|||
{
|
||||
if (hint.regexp.indexIn(cmd) == 0)
|
||||
{
|
||||
//kDebug(7023) << "match - prepending" << (*it).prepend;
|
||||
//kDebug(7023) << "match - prepending" << hint.prepend;
|
||||
const QString cmdStr = hint.prepend + cmd;
|
||||
KUrl url(cmdStr);
|
||||
if (KProtocolInfo::isKnownProtocol(url))
|
||||
|
@ -428,6 +435,23 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const
|
|||
}
|
||||
}
|
||||
|
||||
// NOTE: match for mailto:foo@bar.baz
|
||||
Q_FOREACH(const URLHint& hint, m_urlHints)
|
||||
{
|
||||
if (hint.regexp.indexIn(cmd2) == 0)
|
||||
{
|
||||
//kDebug(7023) << "match - prepending" << hint.prepend;
|
||||
const QString cmdStr = hint.prepend + cmd2;
|
||||
KUrl url(cmdStr);
|
||||
if (KProtocolInfo::isKnownProtocol(url))
|
||||
{
|
||||
setFilteredUri( data, url );
|
||||
setUriType( data, hint.type );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No protocol and not malformed means a valid short URL such as kde.org or
|
||||
// user@192.168.0.1. However, it might also be valid only because it lacks
|
||||
// the scheme component, e.g. www.kde,org (illegal ',' before 'org'). The
|
||||
|
|
Loading…
Add table
Reference in a new issue