Skip to content
Permalink
Browse files

OGR decodeUri: be tolerant on layerName case

Unreported issue: discovered in the QGIS-Documentation
test CI issue
https://travis-ci.org/github/qgis/QGIS-Documentation/builds/734917369#L679
  • Loading branch information
elpaso committed Oct 12, 2020
1 parent 1d2bb41 commit 9b99ecb56f429899ce9c152d30fef626c5bdeaa9
Showing with 18 additions and 3 deletions.
  1. +3 −3 src/core/providers/ogr/qgsogrprovider.cpp
  2. +15 −0 tests/src/python/test_provider_ogr_gpkg.py
@@ -3473,9 +3473,9 @@ QVariantMap QgsOgrProviderMetadata::decodeUri( const QString &uri )

if ( path.contains( '|' ) )
{
const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ) );
const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ) );
const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ) );
const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ), QRegularExpression::PatternOption::CaseInsensitiveOption );
const QRegularExpression subsetRegex( QStringLiteral( "\\|subset=((?:.*[\r\n]*)*)\\Z" ) );
const QRegularExpression openOptionRegex( QStringLiteral( "\\|option:([^|]*)" ) );

@@ -257,11 +257,26 @@ def testDecodeUri(self):
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerName"], 'test')

uri = '{}|layerName=test'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerName"], 'test')

uri = '{}|layerid=0'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerId"], 0)

uri = '{}|layerId=0'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["layerId"], 0)

uri = '{}|geometryType=POINT'.format(filename)
components = registry.decodeUri('ogr', uri)
self.assertEqual(components["path"], filename)
self.assertEqual(components["geometryType"], 'POINT')

def testEncodeUri(self):

filename = '/home/to/path/my_file.gpkg'

0 comments on commit 9b99ecb

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