webbrowser has no escape for os.pathsep
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
aws-sso-util uses the browser module to open the AWS Identity Center login flow.
Sometimes I need to open the login flow in Firefox using a specific container.
The only way I know to open a specific container in Firefox is to use the open-url-in-container extension. It provides a custom protocol handler to follow a URL in a specific container.
So to open the Identity Center start URL in container ABC123, I'd set the BROWSER variable like this before invoking aws-sso-util login:
export BROWSER="firefox ext+container:name=ABC123&url=%s"
But it doesn't work. Instead aws-sso-util prints an error:
Login failed: Failed to open browser
webbrowser.open_new_tab raises an exception to make it print this. (source code).
The problem seems to be the : character in the protocol handler. The doc says the module handles that as list separator.
If the environment variable
BROWSERexists, it is interpreted as the os.pathsep-separated list of browsers to try ahead of the platform defaults. When the value of a list part contains the string %s, then it is interpreted as a literal browser command line to be used with the argument URL substituted for %s; if the part does not contain %s, it is simply interpreted as the name of the browser to launch. [1]
The doc doesn't show any way to escape the :. I've tried \: and :: without any change in behavior.
I also tried URL escaping. This launches the browser, but opens the wrong thing because it no longer recognizes the custom protocol handler.
export BROWSER="firefox ext+container%3Aname=ABC123&url=%s"
Firefox can’t find the file at
/project/ext container:name=ABC123&url=https://d-....awsapps.com/start/#/device?user_code=....
CPython versions tested on:
3.10
Operating systems tested on:
No response
Linked PRs
- gh-152474
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der webbrowser-Dokumentation und dem Einstiegspunkt webbrowser.open_new_tab; reproduzieren Sie den BROWSER-Wert, der mit dem benutzerdefinierten Protokoll-Handler angezeigt wird. Sehen Sie sich die verknüpfte Arbeit gh-152474 und die gemeldete Aufrufstelle in aws_sso_lib/browser.py an und überprüfen Sie anschließend, dass ein Browser-Befehl, der os.pathsep enthält, übergeben werden kann, ohne falsch aufgeteilt zu werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100