Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Lib/mailcap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Mailcap file handling. See RFC 1524."""

import os
import shlex
import subprocess
import warnings

__all__ = ["getcaps","findmatch"]
Expand Down Expand Up @@ -170,7 +172,7 @@ def findmatch(caps, MIMEtype, key='view', filename="/dev/null", plist=[]):
for e in entries:
if 'test' in e:
test = subst(e['test'], filename, plist)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test = subst(e['test'], filename, plist)
test = subst(e['test'], MIMEtype, filename, plist)

Don't know that we should fix this, but this is actually broken if test has a %s in it.

if test and os.system(test) != 0:
if test and subprocess.run(shlex.split(test)).returncode != 0:
continue
command = subst(e[key], MIMEtype, filename, plist)
return command, e
Expand Down Expand Up @@ -250,8 +252,8 @@ def test():
print("No viewer found for", type)
else:
print("Executing:", command)
sts = os.system(command)
sts = os.waitstatus_to_exitcode(sts)
arguments = shlex.split(command)
sts = subprocess.run(arguments, capture_output=True).returncode
if sts:
print("Exit status:", sts)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed CVE-2015-20107 reported against :mod:`mailcap`. Contributed by Oleg Iarygin.