python / python/cpython

webbrowser has no escape for os.pathsep

Ouverte
#133,138 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stdlib type-bug
Langage dominant
Python
Étoiles
77.2k
Forks
36k
Métriques de merge des PR
Métriques de PR en attente

Description

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 BROWSER exists, 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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la documentation de webbrowser et le point d’entrée webbrowser.open_new_tab ; reproduisez la valeur de BROWSER affichée avec le gestionnaire de protocole personnalisé. Examinez le travail associé gh-152474 et le site d’appel signalé dans aws_sso_lib/browser.py, puis vérifiez qu’une commande de navigateur contenant os.pathsep peut être transmise sans être découpée incorrectement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.