Skip to content

Use os.startfile() in WindowsViewer show_file()#9692

Open
radarhere wants to merge 3 commits into
python-pillow:mainfrom
radarhere:shell
Open

Use os.startfile() in WindowsViewer show_file()#9692
radarhere wants to merge 3 commits into
python-pillow:mainfrom
radarhere:shell

Conversation

@radarhere

Copy link
Copy Markdown
Member
  1. WindowsViewer currently uses start from get_command().

Pillow/src/PIL/ImageShow.py

Lines 133 to 135 in 87e7883

def get_command(self, file: str, **options: Any) -> str:
return (
f'start "Pillow" /WAIT "{file}" '

However, a simpler method is to use os.startfile. This prevents injection. The temporary file can be removed after 20 seconds using os.remove(), like 8da8013

  1. As for get_command(), direct injection can be prevented by raising an error if double quotes are used in file. This is valid, because Windows filenames cannot contain them..

  2. Also in get_command(), variable expansion can be prevented by quoting percentages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant