What is the usual practice for disinfecting a file name from an external source (for example, an xml file) before using it as part of a subprocess (shell = False)?
Update: Before posting some parsed lines around, I would like to do some basic security checks. In this example, mpg123 (command line audio player) is used remotely to play the sound file.
filename = child.find("filename").text
pid = subprocess.Popen(["mpg123"],"-R"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
command = "L "+filename+"\n"
pid.stdin.write(command.encode())
source
share