diff --git a/python/plugins/processing/algs/gdal/ogrinfo.py b/python/plugins/processing/algs/gdal/ogrinfo.py
index 5970f034806..aa8d0d28372 100644
--- a/python/plugins/processing/algs/gdal/ogrinfo.py
+++ b/python/plugins/processing/algs/gdal/ogrinfo.py
@@ -74,7 +74,7 @@ class ogrinfo(GdalAlgorithm):
return 'ogrinfo'
def getConsoleCommands(self, parameters, context, feedback, executing=True):
- arguments = [self.commandName(), '-al']
+ arguments = ['-al']
if self.parameterAsBool(parameters, self.SUMMARY_ONLY, context):
arguments.append('-so')
@@ -87,7 +87,7 @@ class ogrinfo(GdalAlgorithm):
connectionString = GdalUtils.ogrConnectionString(inLayer.source(), context)
arguments.append(connectionString)
- return arguments
+ return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
def processAlgorithm(self, parameters, context, feedback):
GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback)
diff --git a/python/plugins/processing/tests/GdalAlgorithmsTest.py b/python/plugins/processing/tests/GdalAlgorithmsTest.py
index fd10cc40695..f84293b770a 100644
--- a/python/plugins/processing/tests/GdalAlgorithmsTest.py
+++ b/python/plugins/processing/tests/GdalAlgorithmsTest.py
@@ -44,6 +44,7 @@ from processing.algs.gdal.GridNearestNeighbor import GridNearestNeighbor
from processing.algs.gdal.buildvrt import buildvrt
from processing.algs.gdal.hillshade import hillshade
from processing.algs.gdal.ogr2ogr import ogr2ogr
+from processing.algs.gdal.ogrinfo import ogrinfo
from processing.algs.gdal.proximity import proximity
from processing.algs.gdal.rasterize import rasterize
from processing.algs.gdal.retile import retile
@@ -1090,6 +1091,48 @@ class TestGdalAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
'-f "LIBKML" "d:/temp/my out/check.kml" ' +
source + ' polys2'])
+ def testOgrInfo(self):
+ context = QgsProcessingContext()
+ feedback = QgsProcessingFeedback()
+ source = os.path.join(testDataPath, 'polys.gml')
+ alg = ogrinfo()
+ alg.initAlgorithm()
+
+ self.assertEqual(
+ alg.getConsoleCommands({'INPUT': source,
+ 'SUMMARY_ONLY': True,
+ 'NO_METADATA': False}, context, feedback),
+ ['ogrinfo',
+ '-al -so ' +
+ source])
+
+ source = os.path.join(testDataPath, 'filename with spaces.gml')
+ self.assertEqual(
+ alg.getConsoleCommands({'INPUT': source,
+ 'SUMMARY_ONLY': True,
+ 'NO_METADATA': False}, context, feedback),
+ ['ogrinfo',
+ '-al -so "' +
+ source + '"'])
+
+ source = os.path.join(testDataPath, 'filename with spaces.gml')
+ self.assertEqual(
+ alg.getConsoleCommands({'INPUT': source,
+ 'SUMMARY_ONLY': False,
+ 'NO_METADATA': False}, context, feedback),
+ ['ogrinfo',
+ '-al "' +
+ source + '"'])
+
+ source = os.path.join(testDataPath, 'filename with spaces.gml')
+ self.assertEqual(
+ alg.getConsoleCommands({'INPUT': source,
+ 'SUMMARY_ONLY': True,
+ 'NO_METADATA': True}, context, feedback),
+ ['ogrinfo',
+ '-al -so -nomd "' +
+ source + '"'])
+
def testHillshade(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
diff --git a/python/plugins/processing/tests/testdata/filename with spaces.gml b/python/plugins/processing/tests/testdata/filename with spaces.gml
new file mode 100644
index 00000000000..e76ccb37907
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/filename with spaces.gml
@@ -0,0 +1,77 @@
+
+
+
+
+ 0-5
+ 83
+
+
+
+
+
+ 1,1
+ 1
+ 2
+
+
+
+
+ 3,3
+ 2
+ 1
+
+
+
+
+ 2,2
+ 3
+ 0
+
+
+
+
+ 5,2
+ 4
+ 2
+
+
+
+
+ 4,1
+ 5
+ 1
+
+
+
+
+ 0,-5
+ 6
+ 0
+
+
+
+
+ 8,-1
+ 7
+ 0
+
+
+
+
+ 7,-1
+ 8
+ 0
+
+
+
+
+ 0,-1
+ 9
+ 0
+
+
+
diff --git a/python/plugins/processing/tests/testdata/filename with spaces.xsd b/python/plugins/processing/tests/testdata/filename with spaces.xsd
new file mode 100644
index 00000000000..ecf1cf46257
--- /dev/null
+++ b/python/plugins/processing/tests/testdata/filename with spaces.xsd
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+