Skip to content

Commit

Permalink
[Processing] GdalUtils: fix quoting of arguments with '&' (fixes #38674)
Browse files Browse the repository at this point in the history
(cherry picked from commit c6fe79b)
  • Loading branch information
rouault authored and nyalldawson committed Oct 23, 2020
1 parent 41185f7 commit 6c70e9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -221,7 +221,7 @@ def escapeAndJoin(strList):
for s in strList:
if not isinstance(s, str):
s = str(s)
if s and s[0] != '-' and ' ' in s:
if s and s[0] != '-' and (' ' in s or '&' in s):
escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \
+ '"'
else:
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsGeneralTest.py
Expand Up @@ -331,6 +331,9 @@ def testCrsConversion(self):
self.assertEqual(GdalUtils.gdal_crs_string(crs),
'+proj=utm +zone=36 +south +a=600000 +b=70000 +towgs84=-143,-90,-294,0,0,0,0 +units=m +no_defs')

def testEscapeAndJoin(self):
self.assertEqual(GdalUtils.escapeAndJoin([1, "a", "a b", "a&b"]), '1 a "a b" "a&b"')


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

0 comments on commit 6c70e9e

Please sign in to comment.