Skip to content

Filter incomplete URLs without a valid TLD from link picker#599

Merged
drn merged 2 commits into
masterfrom
argus/Incomplete-links-should-not
May 15, 2026
Merged

Filter incomplete URLs without a valid TLD from link picker#599
drn merged 2 commits into
masterfrom
argus/Incomplete-links-should-not

Conversation

@drn
Copy link
Copy Markdown
Owner

@drn drn commented May 15, 2026

The greedy URL regex matched partial URLs (https://gi) as the agent
streamed output, leaking them into the TUI ctrl+l picker and the PWA
"Open link" modal. Add a hasValidHost check in internal/links that
requires an IP literal, localhost, or a DNS hostname whose final
label is ≥2 chars starting with a letter — covers .co, .museum,
and xn--* punycode while rejecting no-dot hosts, leading/trailing
dots, one-letter TLDs, and numeric TLDs.

10 new test cases cover the rule. Gotcha doc updated.

Co-Authored-By: Claude noreply@anthropic.com

drn added 2 commits May 15, 2026 11:08
The greedy URL regex matches as the agent streams output, so partial
URLs like `https://gi` leaked into the link picker (TUI ctrl+l and the
PWA Open-link modal). Add a `hasValidHost` check that requires an IP
literal, `localhost`, or a DNS name whose final label is ≥2 chars
starting with a letter — covers `.co` / `.museum` / xn--punycode while
rejecting no-dot hosts, one-letter TLDs, and numeric TLDs.
Followup from review: `hasValidHost` was accepting `https://.example.com`
because `LastIndexByte` found the interior dot and the TLD check passed
on `com`. Reject hostnames with a leading or trailing dot before the
TLD lookup. Clarified the "no dot in host" guard at the same time.
@drn drn merged commit 403af23 into master May 15, 2026
@drn drn deleted the argus/Incomplete-links-should-not branch May 16, 2026 01:30
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.

1 participant