Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main/java/net/bramp/ffmpeg/RunProcessFunction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.bramp.ffmpeg;

import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import java.io.File;
import java.io.IOException;
Expand All @@ -25,8 +24,8 @@ public Process run(List<String> args) throws IOException {
Preconditions.checkNotNull(args, "Arguments must not be null");
Preconditions.checkArgument(!args.isEmpty(), "No arguments specified");

if (LOG.isInfoEnabled()) {
LOG.info("{}", Joiner.on(" ").join(args));
for (String arg : args) {
Preconditions.checkArgument(!isUnsafeArg(arg), "Unsafe protocol specifier in argument");
}

ProcessBuilder builder = new ProcessBuilder(args);
Expand All @@ -37,6 +36,11 @@ public Process run(List<String> args) throws IOException {
return builder.start();
}

private static boolean isUnsafeArg(String arg) {
return arg.regionMatches(true, 0, "data://", 0, 7)
|| arg.regionMatches(true, 0, "gopher://", 0, 9);
}

/** Sets the working directory for the process using a path string. */
public RunProcessFunction setWorkingDirectory(String workingDirectory) {
this.workingDirectory = new File(workingDirectory);
Expand Down
Loading