Skip to content

Commit

Permalink
Fix virtual layer definition decode url ref
Browse files Browse the repository at this point in the history
Fixes #44130
  • Loading branch information
elpaso authored and github-actions[bot] committed Jul 13, 2021
1 parent 02314d4 commit 05427c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/qgsvirtuallayerdefinition.cpp
Expand Up @@ -55,12 +55,12 @@ QgsVirtualLayerDefinition QgsVirtualLayerDefinition::fromUrl( const QUrl &url )
QString layerId, vlayerName;
if ( pos == -1 )
{
layerId = value;
layerId = QUrl::fromPercentEncoding( value.toUtf8() );
vlayerName = QStringLiteral( "vtab%1" ).arg( layerIdx );
}
else
{
layerId = value.left( pos );
layerId = QUrl::fromPercentEncoding( value.left( pos ).toUtf8() );
vlayerName = QUrl::fromPercentEncoding( value.mid( pos + 1 ).toUtf8() );
}
// add the layer to the list
Expand Down
7 changes: 7 additions & 0 deletions tests/src/python/test_qgsvirtuallayerdefinition.py
Expand Up @@ -89,6 +89,13 @@ def test1(self):
self.assertEqual(f[2].name(), f2[2].name())
self.assertEqual(f[2].type(), f2[2].type())

# Issue https://github.com/qgis/QGIS/issues/44130
url = QUrl(r"?layer_ref=Reprojet%C3%A9_e888ce1e_17a9_46f4_b8c3_254eef3f2931:input1&query=SELECT%20*%20FROM%20input1")
f3 = QgsVirtualLayerDefinition.fromUrl(url)
self.assertEqual(f3.query(), 'SELECT * FROM input1')
source_layer = f3.sourceLayers()[0]
self.assertEqual(source_layer.reference(), 'Reprojeté_e888ce1e_17a9_46f4_b8c3_254eef3f2931')


if __name__ == '__main__':
unittest.main()

0 comments on commit 05427c9

Please sign in to comment.