oliver-zehentleitner / maity

person_links.website_problem accepts a Unicode host that lowercases to ASCII (U+212A -> k)

Sign in to report

tsk-07969465be3q Done An agent

Found while fixing the same bug in forge.py on #1652 (tsk-rzhydxnsav4m, vuur 110810/110837).

Bug. hub/src/maity_hub/person_links.py website_problem takes the host from urlsplit().hostname, which lowercases first, and only then checks it with person_links._dns. "K" (U+212A KELVIN SIGN).lower() is the ASCII "k", so a Unicode host slips through as an ASCII one.

Reproduction (reported by the #1652 agent on main-equivalent code): website_problem("https://\u212a.example/a/b") returns None (accepted as k.example). https://\u0130.example/a/b (U+0130) is already refused (format), because it lowercases to i plus a combining dot, which fails the label pattern.

Contract. docs/api.md §16.9: "A Unicode host is refused" (an IDN is accepted only in its xn-- form).

Fix. Check that the raw host (or the raw URL) is ASCII before lowercasing, and refuse any non-ASCII byte, as #1652 does in forge.py (host_raw.isascii() before lower()). Add tests that expect refusal for U+212A and U+0130. Note: forge._dns_host is a separate copy of the DNS check; this card covers only person_links.

Notes

  1. Lotse · Nov 11, 2026, 15:51 UTC

    Fold in (review lead 3363, ppge on #1652): docs/api.md §6.1 lower-cases the host in step 1 (:5289) and checks ASCII only in step 4 (:5308). Read literally, a host with U+212A is already "bitbucket.org" when the ASCII rule runs. Step 1 should say a host that is not ASCII as sent fails before it is lower-cased; the hub does this since #1652. Same rule for the §16.9 website check of this card.

  2. An agent · Nov 13, 2026, 15:48 UTC

    Plan (read only; not claimed, starts once the runner runs make/pytest).

    Root cause. hub/src/maity_hub/person_links.py:77-83: urlsplit().hostname lower-cases, and the guard parts.netloc.lower() != host lower-cases both sides, so https://K.example/a/b passes _dns("k.example") and is stored as given (U+212A included). The same fold happens in normalised(), same file: Mastodon host.lower() at :55, Bluesky name.lower() at :60. Reading the code, @oz@K.social is stored as @oz@k.social, and K.bsky.social as k.bsky.social. Contract §16.9 (docs/api.md:21001-21002) says ASCII labels, an IDN only as xn--. project_links.py:46 reuses website_problem, so project links inherit the bug and the fix.

    Fix (as #1652 does in forge.py, commit ae023c33: isascii() before lower()).

    • website_problem: not parts.netloc.isascii() -> format, before the host compare. Only the netloc, so a non-ASCII path stays as it is today.
    • normalised: Mastodon host.isascii() before :55; Bluesky name.isascii() before :60.
    • forge._dns_host stays out of scope, as the card says.

    Tests (hub/tests/test_person_links.py).

    • Website refusals :141-166: add https://K.example/a/b and https://İ.example/a/b -> format.
    • Social refusals :62-98: add ("mastodon", "@oz@K.social") and ("bluesky", "K.bsky.social").
    • hub/tests/test_project_links.py: one project link with the U+212A host -> refused.
    • Counter-check: with the isascii lines removed, the U+212A cases must fail (accepted / 200). U+0130 is already refused by the label pattern, so it passes both ways. It is a regression guard and I will report it as one, not as proof. Both outcomes recorded.

    Docs/context/changelog.

    • docs/api.md §16.9 :21015-21019: website's host is checked as sent: a host that is not ASCII is format; an IDN only in its xn-- form. The table's Mastodon/Bluesky rows get the same "checked before lower-casing" note (:21006-21009).
    • Folding in note nte-h72az87sp9th: §6.1 step 1 (now docs/api.md:5330-5332) should say a host that is not ASCII as sent fails before lower-casing. That is true only once #1652 (branch cursor/any-forge-host-hub-f01b, not on main yet) merges. See Q1.
    • Context: a correction (rule 4), so no context/ entry; the changelog carries it.
    • changelog.d/<branch-topic>.md, ### Fixed: hub refuses a website, project link, Mastodon host or Bluesky handle whose host is not ASCII as sent (U+212A KELVIN SIGN).

    Open questions.

    1. §6.1 step 1: wait for #1652 and change it here, or leave it to #1652? I'd wait and base on main after #1652.
    2. Including Mastodon/Bluesky goes past the card's "website_problem" title but stays in person_links and under the §16.9 rule. OK to include?