Skip to content
Permalink
Browse files

[ogr] Fix decodeUri unable to handle newline characters in the subset…

… string
  • Loading branch information
nirvn authored and nyalldawson committed Oct 1, 2020
1 parent 80f00f8 commit 7af60f6eb1c4ba44a111e05edd68561cab5cb133
Showing with 3 additions and 3 deletions.
  1. +1 −1 src/core/providers/ogr/qgsogrprovider.cpp
  2. +2 −2 tests/src/core/testqgsogrprovider.cpp
@@ -3433,7 +3433,7 @@ QVariantMap QgsOgrProviderMetadata::decodeUri( const QString &uri )
const QRegularExpression geometryTypeRegex( QStringLiteral( "\\|geometrytype=([a-zA-Z0-9]*)" ) );
const QRegularExpression layerNameRegex( QStringLiteral( "\\|layername=([^|]*)" ) );
const QRegularExpression layerIdRegex( QStringLiteral( "\\|layerid=([^|]*)" ) );
const QRegularExpression subsetRegex( QStringLiteral( "\\|subset=(.*)$" ) );
const QRegularExpression subsetRegex( QStringLiteral( "\\|subset=((?:.*[\r\n]*)*)\\Z" ) );


// we first try to split off the geometry type component, if that's present. That's a known quantity which
@@ -220,12 +220,12 @@ void TestQgsOgrProvider::decodeUri()
QVERIFY( !parts.value( QStringLiteral( "layerId" ) ).isValid() );
QCOMPARE( parts.value( QStringLiteral( "subset" ) ).toString(), QString( "A IN (3,4,5) or \"b\"='x|layerid'" ) );
QCOMPARE( parts.value( QStringLiteral( "path" ) ).toString(), QString( "/path/to/a/geopackage.gpkg" ) );
parts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), QStringLiteral( "/path/to/a/geopackage.gpkg|layerid=4|subset=A IN (3,4,5) or \"b\"='x|layerid'|geometrytype=polygonz|layername=my_subset" ) );
parts = QgsProviderRegistry::instance()->decodeUri( QStringLiteral( "ogr" ), QStringLiteral( "/path/to/a/geopackage.gpkg|layerid=4|subset=A IN (3,4,5) or \n\"b\"='x|layerid'|geometrytype=polygonz|layername=my_subset" ) );
QCOMPARE( parts.size(), 5 );
QCOMPARE( parts.value( QStringLiteral( "layerName" ) ).toString(), QString( "my_subset" ) );
QCOMPARE( parts.value( QStringLiteral( "geometryType" ) ).toString(), QString( "polygonz" ) );
QVERIFY( !parts.value( QStringLiteral( "layerId" ) ).isValid() );
QCOMPARE( parts.value( QStringLiteral( "subset" ) ).toString(), QString( "A IN (3,4,5) or \"b\"='x|layerid'" ) );
QCOMPARE( parts.value( QStringLiteral( "subset" ) ).toString(), QString( "A IN (3,4,5) or \n\"b\"='x|layerid'" ) );
QCOMPARE( parts.value( QStringLiteral( "path" ) ).toString(), QString( "/path/to/a/geopackage.gpkg" ) );
}

0 comments on commit 7af60f6

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