Skip to content

Commit 623a5ab

Browse files
committed
[refactor] Revise mechanism to execute external process
1 parent 1a7a43b commit 623a5ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

extensions/exiftool/src/main/java/org/exist/exiftool/xquery/MetadataFunctions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ private Sequence extractMetadataFromWebResource(String uri) throws XPathExceptio
154154
private Sequence exifToolExtract(final Path binaryFile) throws XPathException {
155155
final ExiftoolModule module = (ExiftoolModule) getParentModule();
156156
try {
157-
final Process p = Runtime.getRuntime().exec(module.getPerlPath() + " " + module.getExiftoolPath() + " -X -struct " + binaryFile.toAbsolutePath());
157+
final String[] command = new String[]{module.getPerlPath(), module.getExiftoolPath(), "-X", "-struct", binaryFile.toAbsolutePath().toString()};
158+
final Process p = Runtime.getRuntime().exec(command);
158159
try(final InputStream stdIn = p.getInputStream();
159160
final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {
160161

@@ -176,7 +177,8 @@ private Sequence exifToolExtract(final Path binaryFile) throws XPathException {
176177
private Sequence exifToolWebExtract(final URI uri) throws XPathException {
177178
final ExiftoolModule module = (ExiftoolModule) getParentModule();
178179
try {
179-
final Process p = Runtime.getRuntime().exec(module.getExiftoolPath()+" -fast -X -");
180+
final String[] command = new String[]{module.getExiftoolPath(), "-fast", "-X", "-"};
181+
final Process p = Runtime.getRuntime().exec(command);
180182

181183
try(final InputStream stdIn = p.getInputStream();
182184
final UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get()) {

0 commit comments

Comments
 (0)