Skip to main content

Module open_browser

Module open_browser 

Source
Expand description

Open URL in the default browser — mirrors packages/coding-agent/src/utils/open-browser.ts.

Cross-platform utility to open a URL in the user’s default browser. Intentionally avoids invoking a shell to prevent command injection from attacker-controlled URLs.

§Platform Support

  • macOS: Uses open command
  • Windows: Uses rundll32 url.dll,FileProtocolHandler
  • Linux/Unix: Uses xdg-open

§Security

This implementation deliberately does NOT use a shell. On Windows, using cmd /c start would allow attacker-controlled URLs to inject metacharacters (&, |, ^, etc.) that cmd.exe re-parses before start runs.

§Example

use rpi_tools::utils::open_browser::open_browser;

// Open a URL in the default browser
if let Err(e) = open_browser("https://example.com") {
    eprintln!("Failed to open browser: {}", e);
}

Functions§

open_browser
open_file
Open a file with the default application. Returns Ok(()) if the launch command was successfully invoked.