Skip to content

Commit d293768

Browse files
Copilotstephentoub
andauthored
Use Uri.Compare for AS issuer comparison (robustness improvement)
Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/101fdc47-ecb5-4163-829b-0b320592a4be Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent af22e21 commit d293768

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,10 @@ private void HandleAuthorizationServerChange(Uri currentIssuer)
10321032
}
10331033

10341034
private static bool UrisAreEquivalent(Uri a, Uri b) =>
1035-
string.Equals(a.AbsoluteUri.TrimEnd('/'), b.AbsoluteUri.TrimEnd('/'), StringComparison.OrdinalIgnoreCase);
1035+
Uri.Compare(a, b,
1036+
UriComponents.Scheme | UriComponents.Host | UriComponents.Port | UriComponents.Path,
1037+
UriFormat.SafeUnescaped,
1038+
StringComparison.OrdinalIgnoreCase) == 0;
10361039

10371040
[DoesNotReturn]
10381041
private static void ThrowFailedToHandleUnauthorizedResponse(string message) =>

0 commit comments

Comments
 (0)