Skip to content

fix(website): classify source badges by URL hostname - #3388

Closed
OKAN-SOFTWARE wants to merge 1 commit into
vinta:masterfrom
OKAN-SOFTWARE:fix/source-badges-url-hostname
Closed

OKAN-SOFTWARE wants to merge 1 commit into
vinta:masterfrom
OKAN-SOFTWARE:fix/source-badges-url-hostname

Conversation

@OKAN-SOFTWARE

Copy link
Copy Markdown

Summary

  • Fix the website's source badge detection to compare parsed URL hostnames against recognized domains.
  • Prevent lookalike hostnames, URL userinfo, and domain strings in paths or query parameters from being mistaken for Python standard-library, GitLab, or Bitbucket sources (or for GitHub links).
  • Preserve legitimate domains, subdomains, and trailing-dot hostnames.

Motivation

Previously, detect_source_type() looked for known domain names anywhere in the URL. For example, https://docs.python.org.lookalike.example/... was classified as Stdlib, even though it was an unrelated site. A similar issue affected GitHub, GitLab, and Bitbucket badges.

Validation

  • Reproduced the incorrect classification with regression tests before applying the fix.
  • uv run pytest website/tests/ -q — 177 passed
  • uv run ruff check . — passed
  • uv run ty check website — passed
  • uv run python website/build.py — passed
  • git diff --check — passed

Changes are scoped to website/build.py and website/tests/test_build.py.

Compare URL hostnames against known source domains instead of
searching for domain text anywhere in an untrusted URL.

Cover lookalike hosts, userinfo, query/path text, subdomains and
trailing-dot hostnames with regression tests.
@vinta

vinta commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks, but I don't think we need this. Every URL in README.md is reviewed before it's merged, so a lookalike hostname like docs.python.org.lookalike.example won't get in.

@vinta vinta closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants