mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-108172: do not override OS preferred browser if it is a super-string of a known browser (GH-113011) (GH-123528)
gh-108172: do not override OS preferred browser if it is a super-string of a known browser (GH-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".
https://github.com/python/cpython/issues/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 10bf615bab
)
Co-authored-by: Oded Arbel <oded@geek.co.il>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
d5abd02f36
commit
bf99818303
2 changed files with 2 additions and 1 deletions
|
@ -30,7 +30,7 @@ def register(name, klass, instance=None, *, preferred=False):
|
||||||
# Preferred browsers go to the front of the list.
|
# Preferred browsers go to the front of the list.
|
||||||
# Need to match to the default browser returned by xdg-settings, which
|
# Need to match to the default browser returned by xdg-settings, which
|
||||||
# may be of the form e.g. "firefox.desktop".
|
# may be of the form e.g. "firefox.desktop".
|
||||||
if preferred or (_os_preferred_browser and name in _os_preferred_browser):
|
if preferred or (_os_preferred_browser and f'{name}.desktop' == _os_preferred_browser):
|
||||||
_tryorder.insert(0, name)
|
_tryorder.insert(0, name)
|
||||||
else:
|
else:
|
||||||
_tryorder.append(name)
|
_tryorder.append(name)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
``webbrowser`` honors OS preferred browser on Linux when its desktop entry name contains the text of a known browser name.
|
Loading…
Add table
Add a link
Reference in a new issue