Skip to content

Commit

Permalink
Handle file:// links in identify text
Browse files Browse the repository at this point in the history
Fixes #29879
  • Loading branch information
elpaso authored and nyalldawson committed May 27, 2019
1 parent cd64b97 commit 5e3ba50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgsstringutils.cpp
Expand Up @@ -409,7 +409,7 @@ QString QgsStringUtils::insertLinks( const QString &string, bool *foundLinks )
// http://alanstorm.com/url_regex_explained
// note - there's more robust implementations available, but we need one which works within the limitation of QRegExp
static QRegExp urlRegEx( "(\\b(([\\w-]+://?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_`{|}~\\s]|/))))" );
static QRegExp protoRegEx( "^(?:f|ht)tps?://" );
static QRegExp protoRegEx( "^(?:f|ht)tps?://|file://" );
static QRegExp emailRegEx( "([\\w._%+-]+@[\\w.-]+\\.[A-Za-z]+)" );

int offset = 0;
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsstringutils.cpp
Expand Up @@ -158,6 +158,8 @@ void TestQgsStringUtils::insertLinks()
QVERIFY( found );
QCOMPARE( QgsStringUtils::insertLinks( QString( "is a@a an email?" ), &found ), QString( "is a@a an email?" ) );
QVERIFY( !found );
QCOMPARE( QgsStringUtils::insertLinks( QString( "Load file:///this/is/path/to.file?query=1#anchor" ), &found ), QString( "Load <a href=\"file:///this/is/path/to.file?query=1#anchor\">file:///this/is/path/to.file?query=1#anchor</a>" ) );
QVERIFY( found );
}

void TestQgsStringUtils::titleCase_data()
Expand Down

0 comments on commit 5e3ba50

Please sign in to comment.