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 134134/// <param name="url">The URL to open.</param>
135135static void OpenBrowser ( Uri url )
136136{
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+
137144 try
138145 {
139146 var psi = new ProcessStartInfo
@@ -145,7 +152,7 @@ static void OpenBrowser(Uri url)
145152 }
146153 catch ( Exception ex )
147154 {
148- Console . WriteLine ( $ "Error opening browser. { ex . Message } ") ;
155+ Console . WriteLine ( $ "Error opening browser: { ex . Message } ") ;
149156 Console . WriteLine ( $ "Please manually open this URL: { url } ") ;
150157 }
151158}
You can’t perform that action at this time.
0 commit comments