File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
samples/ProtectedMcpClient Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 134
134
/// <param name="url">The URL to open.</param>
135
135
static void OpenBrowser ( Uri url )
136
136
{
137
+ // Validate the URI scheme - only allow safe protocols
138
+ if ( url . Scheme != Uri . UriSchemeHttp && url . Scheme != Uri . UriSchemeHttps )
139
+ {
140
+ Console . WriteLine ( $ "Error: Only HTTP and HTTPS URLs are allowed.") ;
141
+ return ;
142
+ }
143
+
137
144
try
138
145
{
139
146
var psi = new ProcessStartInfo
@@ -145,7 +152,7 @@ static void OpenBrowser(Uri url)
145
152
}
146
153
catch ( Exception ex )
147
154
{
148
- Console . WriteLine ( $ "Error opening browser. { ex . Message } ") ;
155
+ Console . WriteLine ( $ "Error opening browser: { ex . Message } ") ;
149
156
Console . WriteLine ( $ "Please manually open this URL: { url } ") ;
150
157
}
151
158
}
You can’t perform that action at this time.
0 commit comments