Skip to content

limit label and message to 255 chars #10998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025
Merged

Conversation

chris48s
Copy link
Member

@chris48s chris48s commented Apr 5, 2025

Currently we don't place any limit on the size of a label or message
This means you can make badges with really long text, for example:

- https://img.shields.io/badge/long-It%20was%20the%20best%20of%20times%2C%20it%20was%20the%20worst%20of%20times%2C%20it%20was%20the%20age%20of%20wisdom%2C%20it%20was%20the%20age%20of%20foolishness%2C%20it%20was%20the%20epoch%20of%20belief%2C%20it%20was%20the%20epoch%20of%20incredulity%2C%20it%20was%20the%20season%20of%20Light%2C%20it%20was%20the%20season%20of%20Darkness%2C%20it%20was%20the%20spring%20of%20hope%2C%20it%20was%20the%20winter%20of%20despair%2C%20we%20had%20everything%20before%20us%2C%20we%20had%20nothing%20before%20us%2C%20we%20were%20all%20going%20direct%20to%20Heaven%2C%20we%20were%20all%20going%20direct%20the%20other%20way%E2%80%94in%20short%2C%20the%20period%20was%20so%20far%20like%20the%20present%20period%2C%20that%20some%20of%20its%20noisiest%20authorities%20insisted%20on%20its%20being%20received%2C%20for%20good%20or%20for%20evil%2C%20in%20the%20superlative%20degree%20of%20comparison%20only-blue

That is not particularly useful. With the dyanmic and endpoint badges you can construct relatively small requests that force us to render a single SVG containing up to about 10Mb of text (the largest response size we will accept from an upstream URL). Here's a less extreme example that proves the concept:

- https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Foronoa%2Fredoc_sample%2F8c98482a7eb649aa1fa0f9992ef78997c5217371%2Finfo.yml&query=%24.info.description

In this PR, I propose imposing a limit on the size of the message and label fields we will render. 255 characters seems like more than enough to render all useful badges.

I've done this in shields.io core rather than badge-maker. Badge-maker library users can render any length of text

@chris48s chris48s added the core Server, BaseService, GitHub auth, Shared helpers label Apr 5, 2025
Copy link
Contributor

github-actions bot commented Apr 5, 2025

Messages
📖 ✨ Thanks for your contribution to Shields, @chris48s!

Generated by 🚫 dangerJS against 5ac1c88

@chris48s chris48s merged commit 945d1ab into badges:master Apr 19, 2025
24 checks passed
chris48s added a commit to chris48s/shields that referenced this pull request Apr 19, 2025
chris48s added a commit that referenced this pull request Apr 26, 2025
chris48s added a commit that referenced this pull request Apr 26, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 26, 2025
…l eclipse jetbrains maven nuget] (#11030)

* chore(deps): bump fast-xml-parser from 5.2.0 to 5.2.1

Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 5.2.0 to 5.2.1.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](NaturalIntelligence/fast-xml-parser@v5.2.0...v5.2.1)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-version: 5.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* update dynamic xml test

refs #10998

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Server, BaseService, GitHub auth, Shared helpers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant