|
@@ -20,7 +20,7 @@ __date__ = 'November 2024'
|
|
__copyright__ = '(C) 2024, wanger'
|
|
__copyright__ = '(C) 2024, wanger'
|
|
|
|
|
|
import os
|
|
import os
|
|
-
|
|
+import re
|
|
from PyQt5.QtGui import QIcon
|
|
from PyQt5.QtGui import QIcon
|
|
|
|
|
|
from qgis._core import QgsProcessingParameterFile
|
|
from qgis._core import QgsProcessingParameterFile
|
|
@@ -273,8 +273,8 @@ class Ogr2PostGisList(GdalAlgorithm):
|
|
else:
|
|
else:
|
|
table = f'{schema}.{table}'
|
|
table = f'{schema}.{table}'
|
|
|
|
|
|
- arguments.append(file)
|
|
+ arguments.append(f'"{file}"')
|
|
- arguments.append(table)
|
|
+ arguments.append(f'"{table}"')
|
|
|
|
|
|
|
|
|
|
arguments.append('|')
|
|
arguments.append('|')
|
|
@@ -293,9 +293,25 @@ class Ogr2PostGisList(GdalAlgorithm):
|
|
|
|
|
|
if isWindows():
|
|
if isWindows():
|
|
return ['cmd.exe', '/C ', 'raster2pgsql.exe',
|
|
return ['cmd.exe', '/C ', 'raster2pgsql.exe',
|
|
- GdalUtils.escapeAndJoin(arguments)]
|
|
+ self.escapeAndJoin(arguments)]
|
|
else:
|
|
else:
|
|
- return ['raster2pgsql', GdalUtils.escapeAndJoin(arguments)]
|
|
+ return ['raster2pgsql', self.escapeAndJoin(arguments)]
|
|
|
|
+ def escapeAndJoin(self, strList):
|
|
|
|
+ escChars = [' ', '&', '(', ')', '"', ';']
|
|
|
|
+ joined = ''
|
|
|
|
+ for s in strList:
|
|
|
|
+ if not isinstance(s, str):
|
|
|
|
+ s = str(s)
|
|
|
|
+
|
|
|
|
+ if s and re.match(r'^([^-]|-\d)', s) and any(c in s for c in escChars):
|
|
|
|
+ escaped = s
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ else:
|
|
|
|
+ escaped = s
|
|
|
|
+ if escaped is not None:
|
|
|
|
+ joined += escaped + ' '
|
|
|
|
+ return joined.strip()
|
|
|
|
|
|
def commandName(self):
|
|
def commandName(self):
|
|
return "raster2pgsql"
|
|
return "raster2pgsql"
|