From bbc35accfddfa6413106bfa7cb7c2cfa5dbbfcdd Mon Sep 17 00:00:00 2001 From: Kevin Wang <453587854@qq.com> Date: Wed, 7 Aug 2019 02:07:16 +0800 Subject: [PATCH] underscores should be allowed in domain names [It is perfectly legal to have an underscore in a domain name.](https://stackoverflow.com/a/2183140/6247478) I fixed `validateDomainName` so that users who are given a domain name with underscores will not be prevented from using this software. --- ShadowsocksX-NG/ServerProfile.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShadowsocksX-NG/ServerProfile.swift b/ShadowsocksX-NG/ServerProfile.swift index bd80833..5e558be 100644 --- a/ShadowsocksX-NG/ServerProfile.swift +++ b/ShadowsocksX-NG/ServerProfile.swift @@ -131,7 +131,7 @@ class ServerProfile: NSObject { } func validateDomainName(_ value: String) -> Bool { - let validHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$" + let validHostnameRegex = "^(([a-zA-Z0-9_]|[a-zA-Z0-9_][a-zA-Z0-9\\-_]*[a-zA-Z0-9_])\\.)*([A-Za-z0-9_]|[A-Za-z0-9_][A-Za-z0-9\\-_]*[A-Za-z0-9_])$" if (value.range(of: validHostnameRegex, options: .regularExpression) != nil) { return true