fix: allow non-ASCII characters in SSH host aliases#3154
fix: allow non-ASCII characters in SSH host aliases#3154majiayu000 wants to merge 2 commits intowavetermdev:mainfrom
Conversation
The userHostRe regexp only accepted ASCII letters and digits in the
host portion, rejecting valid SSH config Host aliases that contain
Chinese or other Unicode characters (e.g. "PROD-服务器"). Widen the
character classes with \p{L} and \p{N} to accept Unicode letters
and digits.
Fixes wavetermdev#2937
Signed-off-by: majiayu000 <1835304752@qq.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis pull request updates the Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
The new test case Reviewed by minimax-m2.5 · incremental review from e1b6080 Reviewed by minimax-m2.5-20260211 · 196,102 tokens |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/remote/connutil_test.go (1)
19-24: Add one Unicode-username test case for full parser coverage.Current tests validate Unicode host aliases well; adding a Unicode
user@hostcase would lock in the expanded username behavior too.Suggested test additions
func TestParseOpts(t *testing.T) { tests := []struct { @@ {"mixed ascii and chinese with user and port", "user@PROD-阿里云:22", "user", "PROD-阿里云", "22", false}, + {"unicode user and host", "用户@服务器:22", "用户", "服务器", "22", false}, {"unicode only host", "服务器", "", "服务器", "", false}, {"japanese host", "サーバー", "", "サーバー", "", false},🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/remote/connutil_test.go` around lines 19 - 24, Add a test row to the test table in pkg/remote/connutil_test.go that covers a Unicode username (e.g., an entry with address like "用户@服务器"), expecting parsed user "用户", host "服务器", empty port and success=false as appropriate for other cases; update the same table used by the test that asserts parsed user/host/port (the table of cases in connutil_test.go) so the existing parser/assertion logic picks up and validates the Unicode username parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/remote/connutil_test.go`:
- Around line 19-24: Add a test row to the test table in
pkg/remote/connutil_test.go that covers a Unicode username (e.g., an entry with
address like "用户@服务器"), expecting parsed user "用户", host "服务器", empty port and
success=false as appropriate for other cases; update the same table used by the
test that asserts parsed user/host/port (the table of cases in connutil_test.go)
so the existing parser/assertion logic picks up and validates the Unicode
username parsing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 804103c7-2c09-44d2-8bb8-21b20f6a2b3d
📒 Files selected for processing (2)
pkg/remote/connutil.gopkg/remote/connutil_test.go
Signed-off-by: majiayu000 <1835304752@qq.com>
Fixes #2937
userHostReinpkg/remote/connutil.goonly matched[a-zA-Z0-9]for the host portion, so SSH Host aliases with Chinese (or other non-ASCII) characters failed validation.Added
\p{L}and\p{N}Unicode classes to the regexp so it accepts Unicode letters and digits in both host and user parts. Go's regexp package supports these natively.Tests added in
pkg/remote/connutil_test.gocovering Chinese, Japanese, mixed, and ASCII-only inputs.