webbrowser has no escape for os.pathsep
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla documentazione di webbrowser e dal punto di ingresso webbrowser.open_new_tab; riproduci il valore di BROWSER mostrato con il gestore di protocollo personalizzato. Esamina il lavoro collegato gh-152474 e il sito della chiamata segnalato in aws_sso_lib/browser.py, quindi verifica che un comando del browser contenente os.pathsep possa essere passato senza essere suddiviso in modo errato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100