Skip to content
Permalink
Browse files
Fix virtual layer definition decode url ref
Fixes #44130
  • Loading branch information
elpaso committed Jul 13, 2021
1 parent 494735a commit 117a05472ee762e0b92c41a71476b5fa168fc356
Showing with 9 additions and 2 deletions.
  1. +2 −2 src/core/qgsvirtuallayerdefinition.cpp
  2. +7 −0 tests/src/python/test_qgsvirtuallayerdefinition.py
@@ -56,12 +56,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
@@ -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 117a054

Please sign in to comment.