Commit d5cfdfb5 authored by Sergey Toshin's avatar Sergey Toshin Committed by Skylot

Prevents command injections when opening links

parent 2e5d73a7
......@@ -66,16 +66,22 @@ public class Link extends JLabel implements MouseListener {
try {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
new ProcessBuilder()
.command(new String[] {"rundll32", "url.dll,FileProtocolHandler", url})
.start();
return;
}
if (os.contains("mac")) {
Runtime.getRuntime().exec("open " + url);
new ProcessBuilder()
.command(new String[] {"open", url})
.start();
return;
}
Map<String, String> env = System.getenv();
if (env.get("BROWSER") != null) {
Runtime.getRuntime().exec(env.get("BROWSER") + " " + url);
new ProcessBuilder()
.command(new String[] {env.get("BROWSER"), url})
.start();
return;
}
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment