File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -242,9 +242,26 @@ public static void OpenInFileManager(string path)
242242
243243 public static void OpenBrowser ( string url )
244244 {
245+ if ( ! IsSafeBrowserTarget ( url ) )
246+ {
247+ Models . Notification . Send ( null , $ "Blocked unsafe URL: { url } ", true ) ;
248+ return ;
249+ }
250+
245251 _backend . OpenBrowser ( url ) ;
246252 }
247253
254+ private static bool IsSafeBrowserTarget ( string url )
255+ {
256+ return Uri . IsWellFormedUriString ( url , UriKind . Absolute ) &&
257+ Uri . TryCreate ( url , UriKind . Absolute , out var uri ) &&
258+ (
259+ uri . Scheme == Uri . UriSchemeHttp ||
260+ uri . Scheme == Uri . UriSchemeHttps ||
261+ uri . Scheme == Uri . UriSchemeFtp
262+ ) ;
263+ }
264+
248265 public static void OpenTerminal ( string workdir )
249266 {
250267 if ( string . IsNullOrEmpty ( ShellOrTerminal ) )
Original file line number Diff line number Diff line change @@ -133,7 +133,8 @@ public string FindTerminal(Models.ShellOrTerminal shell)
133133
134134 public void OpenBrowser ( string url )
135135 {
136- var info = new ProcessStartInfo ( "cmd" , $ """ /c start "" { url . Quoted ( ) } """ ) ;
136+ var info = new ProcessStartInfo ( url ) ;
137+ info . UseShellExecute = true ;
137138 info . CreateNoWindow = true ;
138139 Process . Start ( info ) ;
139140 }
You can’t perform that action at this time.
0 commit comments