python / python/cpython

webbrowser has no escape for os.pathsep

Aberta
#133,138 2 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece pela documentação de webbrowser e pelo ponto de entrada webbrowser.open_new_tab; reproduza o valor de BROWSER mostrado com o manipulador de protocolo personalizado. Revise o trabalho relacionado gh-152474 e o ponto de chamada relatado em aws_sso_lib/browser.py, depois verifique se um comando do navegador contendo os.pathsep pode ser passado sem ser dividido incorretamente.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
tooling
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.