Merge pull request #33 from SamJakob/patch-1

Fix Scyther process call on Windows (escape paths)
This commit is contained in:
Cas Cremers 2023-02-01 20:52:49 +01:00 committed by GitHub
commit 1fae53a672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,6 +90,9 @@ def getCacheDir():
if tmpdir != None: if tmpdir != None:
tmpdir = os.path.join(tmpdir,"Scyther-cache") tmpdir = os.path.join(tmpdir,"Scyther-cache")
# Normalize the tmpdir path.
tmpdir = os.path.normpath(tmpdir)
return tmpdir return tmpdir
@ -398,8 +401,14 @@ class Scyther(object):
# Generate temporary files for the output. # Generate temporary files for the output.
(fde,fne) = tempfile.mkstemp() # errors (fde,fne) = tempfile.mkstemp() # errors
(fdo,fno) = tempfile.mkstemp() # output (fdo,fno) = tempfile.mkstemp() # output
# Normalize the temporary paths.
fne = os.path.normpath(fne)
fno = os.path.normpath(fno)
if spdl: if spdl:
(fdi,fni) = tempfile.mkstemp() # input (fdi,fni) = tempfile.mkstemp() # input
fni = os.path.normpath(fni)
# Write (input) file # Write (input) file
fhi = os.fdopen(fdi,'w+') fhi = os.fdopen(fdi,'w+')
@ -409,14 +418,14 @@ class Scyther(object):
# Generate command line for the Scyther process # Generate command line for the Scyther process
self.cmd = "" self.cmd = ""
self.cmd += "\"%s\"" % self.program self.cmd += "\"%s\"" % self.program
self.cmd += " --append-errors=%s" % fne self.cmd += " --append-errors=\"%s\"" % fne
self.cmd += " --append-output=%s" % fno self.cmd += " --append-output=\"%s\"" % fno
self.cmd += " %s" % args self.cmd += " %s" % args
if spdl: if spdl:
self.cmd += " %s" % fni self.cmd += " \"%s\"" % fni
# Only for debugging, really # Only for debugging, really
##print self.cmd # print( self.cmd )
# Start the process # Start the process
safeCommand(self.cmd, storePopen=storePopen) safeCommand(self.cmd, storePopen=storePopen)