summaryrefslogtreecommitdiffstats
path: root/Lib/webbrowser.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2019-06-24 15:42:54 (GMT)
committerGitHub <noreply@github.com>2019-06-24 15:42:54 (GMT)
commit60419a7e96577cf783b3b45bf3984f9fb0d7ddff (patch)
tree2718cb915663c42902621491ba60accce6729d42 /Lib/webbrowser.py
parent9bbf4d7083a819cbcee2a6cd3df2802d4c50f734 (diff)
downloadcpython-60419a7e96577cf783b3b45bf3984f9fb0d7ddff.zip
cpython-60419a7e96577cf783b3b45bf3984f9fb0d7ddff.tar.gz
cpython-60419a7e96577cf783b3b45bf3984f9fb0d7ddff.tar.bz2
bpo-37363: Add audit events for a range of modules (GH-14301)
Diffstat (limited to 'Lib/webbrowser.py')
-rwxr-xr-xLib/webbrowser.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index 82bff83..0af36c4 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -154,6 +154,7 @@ class GenericBrowser(BaseBrowser):
self.basename = os.path.basename(self.name)
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
cmdline = [self.name] + [arg.replace("%s", url)
for arg in self.args]
try:
@@ -173,6 +174,7 @@ class BackgroundBrowser(GenericBrowser):
def open(self, url, new=0, autoraise=True):
cmdline = [self.name] + [arg.replace("%s", url)
for arg in self.args]
+ sys.audit("webbrowser.open", url)
try:
if sys.platform[:3] == 'win':
p = subprocess.Popen(cmdline)
@@ -201,7 +203,7 @@ class UnixBrowser(BaseBrowser):
remote_action_newwin = None
remote_action_newtab = None
- def _invoke(self, args, remote, autoraise):
+ def _invoke(self, args, remote, autoraise, url=None):
raise_opt = []
if remote and self.raise_opts:
# use autoraise argument only for remote invocation
@@ -237,6 +239,7 @@ class UnixBrowser(BaseBrowser):
return not p.wait()
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
if new == 0:
action = self.remote_action
elif new == 1:
@@ -253,7 +256,7 @@ class UnixBrowser(BaseBrowser):
args = [arg.replace("%s", url).replace("%action", action)
for arg in self.remote_args]
args = [arg for arg in args if arg]
- success = self._invoke(args, True, autoraise)
+ success = self._invoke(args, True, autoraise, url)
if not success:
# remote invocation failed, try straight way
args = [arg.replace("%s", url) for arg in self.args]
@@ -337,6 +340,7 @@ class Konqueror(BaseBrowser):
"""
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
# XXX Currently I know no way to prevent KFM from opening a new win.
if new == 2:
action = "newTab"
@@ -420,6 +424,7 @@ class Grail(BaseBrowser):
return 1
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
if new:
ok = self._remote("LOADNEW " + url)
else:
@@ -577,6 +582,7 @@ def register_standard_browsers():
if sys.platform[:3] == "win":
class WindowsDefault(BaseBrowser):
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
try:
os.startfile(url)
except OSError:
@@ -606,6 +612,7 @@ if sys.platform == 'darwin':
self.name = name
def open(self, url, new=0, autoraise=True):
+ sys.audit("webbrowser.open", url)
assert "'" not in url
# hack for local urls
if not ':' in url: