Web panel: IsAllowed fails closed on invalid IDN hosts
Uri.IdnHost throws UriFormatException for hosts like c<U+2100>; catch and reject. Test project now runs with ICU so the case is covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0b0d2cb072
commit
e428f65c4d
3 changed files with 6 additions and 2 deletions
|
|
@ -77,7 +77,9 @@ internal static class WebPanelUrlPolicy
|
|||
if (uri.UserInfo.Length != 0) return false;
|
||||
if (!uri.IsDefaultPort) return false;
|
||||
|
||||
string host = uri.IdnHost.ToLowerInvariant();
|
||||
string host;
|
||||
try { host = uri.IdnHost.ToLowerInvariant(); }
|
||||
catch (UriFormatException) { return false; } // invalid IDN characters: fail closed
|
||||
if (host.EndsWith('.')) host = host.Substring(0, host.Length - 1);
|
||||
if (host.Length == 0) return false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue