Skip to content

Commit bf99818

Browse files
miss-islingtonguss77AlexWaygood
authored
[3.12] pythongh-108172: do not override OS preferred browser if it is a super-string of a known browser (pythonGH-113011) (pythonGH-123528)
pythongh-108172: do not override OS preferred browser if it is a super-string of a known browser (pythonGH-113011) When checking if the registering browser is the "OS preferred browser", do not use a substring search - that makes no sense: one can have a preferred browser that looks like a super-string of a known browser, e.g. "firefox-nightly" vs "firefox". python#108172 explains in more detail, and lays out a potential better future enhancement for this case of just using xdg-open. We'll go with this for now. --------- (cherry picked from commit 10bf615) Co-authored-by: Oded Arbel <oded@geek.co.il> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent d5abd02 commit bf99818

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/webbrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def register(name, klass, instance=None, *, preferred=False):
3030
# Preferred browsers go to the front of the list.
3131
# Need to match to the default browser returned by xdg-settings, which
3232
# may be of the form e.g. "firefox.desktop".
33-
if preferred or (_os_preferred_browser and name in _os_preferred_browser):
33+
if preferred or (_os_preferred_browser and f'{name}.desktop' == _os_preferred_browser):
3434
_tryorder.insert(0, name)
3535
else:
3636
_tryorder.append(name)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``webbrowser`` honors OS preferred browser on Linux when its desktop entry name contains the text of a known browser name.

0 commit comments

Comments
 (0)