Skip to content
Permalink
Browse files

GUI: renaming GPKG layer: allow any character but | (fixes #39288)

  • Loading branch information
rouault authored and nyalldawson committed Oct 10, 2020
1 parent 9d06186 commit f940ffc6d0db4aaa818e0debc93269f1f889cdf5
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/gui/providers/ogr/qgsgeopackageitemguiprovider.cpp
@@ -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 >();
@@ -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 );

0 comments on commit f940ffc

Please sign in to comment.
You can’t perform that action at this time.