Skip to content

Commit

Permalink
GUI: renaming GPKG layer: allow any character but | (fixes #39288)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and nyalldawson committed Oct 10, 2020
1 parent 9d06186 commit f940ffc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp
Expand Up @@ -262,6 +262,7 @@ void QgsGeoPackageItemGuiProvider::renameVectorLayer()
QVariantMap data = s->data().toMap();
const QString uri = data[QStringLiteral( "uri" )].toString();
const QString key = data[QStringLiteral( "key" )].toString();
// Collect existing table names
const QStringList tableNames = data[QStringLiteral( "tableNames" )].toStringList();
QPointer< QgsDataItem > item = data[QStringLiteral( "item" )].value<QPointer< QgsDataItem >>();
QgsDataItemGuiContext context = data[QStringLiteral( "context" )].value< QgsDataItemGuiContext >();
Expand All @@ -270,8 +271,10 @@ void QgsGeoPackageItemGuiProvider::renameVectorLayer()
QVariantMap pieces( QgsProviderRegistry::instance()->decodeUri( key, uri ) );
QString layerName = pieces[QStringLiteral( "layerName" )].toString();

// Collect existing table names
const QRegExp checkRe( QStringLiteral( R"re([A-Za-z_][A-Za-z0-9_\s]+)re" ) );
// Allow any character, except |, which could create confusion, due to it being
// the URI componenent separator. And ideally we should remove that restriction
// by using proper escaping of |
const QRegExp checkRe( QStringLiteral( R"re([^|]+)re" ) );
QgsNewNameDialog dlg( uri, layerName, QStringList(), tableNames, checkRe );
dlg.setOverwriteEnabled( false );

Expand Down

0 comments on commit f940ffc

Please sign in to comment.