Shields: Path builder should percent-encode route components

Created on 3 May 2020  Β·  4Comments  Β·  Source: badges/shields

Are you experiencing an issue with...

  • [x] [shields.io](https://shields.io/#/)
  • [ ] My own instance
  • [ ] [badge-maker NPM package](https://www.npmjs.com/package/badge-maker)

:beetle: Description

Generated links may contain unencoded spaces which breaks links in certain markups (like RST).

:link: Link to the badge

https://img.shields.io/github/workflow/status/ansible/pylibssh/%F0%9F%8F%97%20%F0%9F%93%A6%20&%20test%20&%20publish/devel

The problem was that shields.io generated RST with a link that had spaces. So it was https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel?label=GitHub%20Actions%20%5Btests%5D&logo=github instead of https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ—%20πŸ“¦%20&%20test%20&%20publish/devel?label=GitHub%20Actions%20%5Btests%5D&logo=github

:bulb: Possible Solution

I've fixed this for my repo with https://github.com/ansible/pylibssh/commit/66a1a2bb5a5b4e674cd3c2a2e9e0aafefe48292f but I think shields.io should generate proper links, at least having spaces %-encoded.

bug frontend

Most helpful comment

https://shields.io/category/build -> GitHub Workflow Status (branch) -> enter ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel -> Copy Badge URL (or Copy reStructuredText) -> https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel which is wrong because most of the parsers will recognize only the part before the first space as a URL.

The copied RST is broken therefore too:

.. image:: https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel
   :alt: GitHub Workflow Status (branch)

_(and also it's copied as a one-line thing but should be two lines which is its own separate bug)_

The copied URL should be https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ—%20πŸ“¦%20&%20test%20&%20publish/devel instead.

All 4 comments

(label should be bug: #5043)

Hi! It sounds like this is a problem in the frontend, yea? Could you clarify the steps to reproduce? i.e. what need to be filled into which fields?

Are you clicking Copy Badge URL at the end or are you using the RsT option? If the RsT, does the problem still manifest if you use Copy Badge URL?

https://shields.io/category/build -> GitHub Workflow Status (branch) -> enter ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel -> Copy Badge URL (or Copy reStructuredText) -> https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel which is wrong because most of the parsers will recognize only the part before the first space as a URL.

The copied RST is broken therefore too:

.. image:: https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ— πŸ“¦ & test & publish/devel
   :alt: GitHub Workflow Status (branch)

_(and also it's copied as a one-line thing but should be two lines which is its own separate bug)_

The copied URL should be https://img.shields.io/github/workflow/status/ansible/pylibssh/πŸ—%20πŸ“¦%20&%20test%20&%20publish/devel instead.

Thanks for the steps! It's super helpful to have a detailed report.

It seems to me this may be a bug or feature request in path-to-regexp… though it might also be something we have to deal with ourselves.

The fix might be as simple as URL-encoding the path segments, though that will URL-encode everything, including some characters which I think in practice work just fine in URLs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukeeey picture lukeeey  Β·  3Comments

rominf picture rominf  Β·  3Comments

PyvesB picture PyvesB  Β·  3Comments

niccokunzmann picture niccokunzmann  Β·  3Comments

stclairdaniel picture stclairdaniel  Β·  3Comments