@@ -89,7 +89,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
8989 command = "java -jar ./apktool-cli-all.jar" ;
9090 }
9191 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
92- command += " d -f -s -m -k -o " + new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool" ).getAbsolutePath () + " \" " + argumentPackage .getApk ().getAbsolutePath () + " \" " ;
92+ command += " d -f -s -m -k -o " + encapsulate ( new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool" ).getAbsolutePath ()) + " " + encapsulate ( argumentPackage .getApk ().getAbsolutePath ()) ;
9393
9494 workingDirectory = new File (Constants .APKTOOL_LIBRARY_FOLDER );
9595 executeCommand (DecompilerType .APKTOOL , command , workingDirectory );
@@ -112,7 +112,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
112112 command = "java -jar ./apktool-cli-all.jar" ;
113113 }
114114 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
115- command += " d -f --no-assets --no-res -m -o " + new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool-smali" ).getAbsolutePath () + " \" " + argumentPackage .getApk ().getAbsolutePath () + " \" " ;
115+ command += " d -f --no-assets --no-res -m -o " + encapsulate ( new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool-smali" ).getAbsolutePath ()) + " " + encapsulate ( argumentPackage .getApk ().getAbsolutePath ()) ;
116116
117117 workingDirectory = new File (Constants .APKTOOL_LIBRARY_FOLDER );
118118 executeCommand (DecompilerType .APKTOOL , command , workingDirectory );
@@ -139,7 +139,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
139139 command = "sh ./d2j-dex2jar.sh" ;
140140 }
141141 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
142- command += " -n -f -o " + new File (Constants .TEMP_CONVERTED_JAR ) + " " + new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool/classes.dex" ).getAbsolutePath ();
142+ command += " -n -f -o " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ). getAbsolutePath ()) + " " + encapsulate ( new File (Constants .TEMP_LIBRARY_FOLDER + "/apktool/classes.dex" ).getAbsolutePath () );
143143 workingDirectory = new File (Constants .DEX2JAR_LIBRARY_FOLDER );
144144 executeCommand (DecompilerType .DEX2JAR , command , workingDirectory );
145145
@@ -157,7 +157,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
157157 command = "java -jar ./fernflower.jar" ;
158158 }
159159 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
160- command += " " + new File (Constants .TEMP_CONVERTED_JAR ) + " " + new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath ();
160+ command += " " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ). getAbsolutePath ()) + " " + encapsulate ( new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath () );
161161 workingDirectory = new File (Constants .FERNFLOWER_LIBRARY_FOLDER );
162162 break ;
163163 case JADX :
@@ -182,7 +182,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
182182 command = "sh ./jadx" ;
183183 }
184184 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
185- command += " -r --escape-unicode -d " + new File (Constants .TEMP_LIBRARY_FOLDER ).getAbsolutePath () + " " + new File (Constants .TEMP_CONVERTED_JAR );
185+ command += " -r --escape-unicode -d " + encapsulate ( new File (Constants .TEMP_LIBRARY_FOLDER ).getAbsolutePath ()) + " " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ). getAbsolutePath () );
186186 workingDirectory = new File (Constants .JADX_LIBRARY_FOLDER );
187187 break ;
188188 case JDCMD :
@@ -196,7 +196,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
196196 command = "java -jar ./jd-cli.jar" ;
197197 }
198198 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
199- command += " -od " + new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath () + " " + new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath ();
199+ command += " -od " + encapsulate ( new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath ()) + " " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath () );
200200 workingDirectory = new File (Constants .JDCMD_LIBRARY_FOLDER );
201201 break ;
202202 case CFR :
@@ -229,7 +229,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
229229 command = "java -jar " + cfrFileName ;
230230 }
231231 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
232- command += " " + new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath () + " --aexagg true --outputdir " + new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath ();
232+ command += " " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath ()) + " --aexagg true --outputdir " + encapsulate ( new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath () );
233233 workingDirectory = new File (Constants .CFR_LIBRARY_FOLDER );
234234 break ;
235235 case PROCYON :
@@ -247,7 +247,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
247247 command = "java -jar ./procyon-decompiler-0.5.30.jar" ;
248248 }
249249 //Append the flags and the file paths to the commands. These are the same on any platform due to the Java runtime
250- command += " -ci -eml --jar-file " + new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath () + " -o " + new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath ();
250+ command += " -ci -eml --jar-file " + encapsulate ( new File (Constants .TEMP_CONVERTED_JAR ).getAbsolutePath ()) + " -o " + encapsulate ( new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath () );
251251 workingDirectory = new File (Constants .PROCYON_LIBRARY_FOLDER );
252252 break ;
253253 case JEB3 :
@@ -265,7 +265,7 @@ public void decompile() throws IOException, InterruptedException, ZipException {
265265 } else {
266266 command = "java -jar ./bin/app/jeb.jar" ;
267267 }
268- command += " --srv2 --script=" + new File (Constants .JEB3_CLI_ANDROID_SCRIPT_LIBRARY_FOLDER + "/DecompileAndroid.py" ).getAbsolutePath () + " -- " + argumentPackage .getApk ().getAbsolutePath () + " " + new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath ();
268+ command += " --srv2 --script=" + encapsulate ( new File (Constants .JEB3_CLI_ANDROID_SCRIPT_LIBRARY_FOLDER + "/DecompileAndroid.py" ).getAbsolutePath ()) + " -- " + encapsulate ( argumentPackage .getApk ().getAbsolutePath ()) + " " + encapsulate ( new File (Constants .TEMP_SOURCES_FOLDER ).getAbsolutePath () );
269269 workingDirectory = argumentPackage .getJeb3Folder ();
270270 }
271271 executeCommand (argumentPackage .getDecompilerType (), command , workingDirectory );
@@ -312,4 +312,14 @@ private void executeCommand(DecompilerType name, String commandString, File work
312312 throw new IOException ("Something went wrong with the I/O during the decompilation. Check the permissions of the output directory and try again." );
313313 }
314314 }
315+
316+ /**
317+ * Encapsulates the given string between quotes
318+ *
319+ * @param value the string to encapsulate
320+ * @return the encapsulated string
321+ */
322+ private String encapsulate (String value ) {
323+ return "\" " + value + "\" " ;
324+ }
315325}
0 commit comments