Skip to content

Commit

Permalink
Support filelist files with quoted file names
Browse files Browse the repository at this point in the history
  • Loading branch information
ebourg committed May 16, 2024
1 parent 63719b5 commit 46eb00e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion jsign-cli/src/main/java/net/jsign/JsignCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void execute(String... args) throws SignerException, ParseException {
for (String arg : cmd.getArgList()) {
for (String filename : expand(arg)) {
if (!filename.trim().isEmpty() && !filename.startsWith("#")) {
helper.execute(new File(filename));
helper.execute(new File(unquote(filename)));
}
}
}
Expand Down Expand Up @@ -204,6 +204,17 @@ private List<String> readFile(File file) throws IOException {
}
}

/**
* Removes the quotes around the specified file name.
*/
private String unquote(String value) {
value = value.trim();
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
}
return value;
}

private void setOption(String key, SignerHelper helper, CommandLine cmd) {
String value = cmd.getOptionValue(key);
helper.param(key, value);
Expand Down
2 changes: 1 addition & 1 deletion jsign-cli/src/test/java/net/jsign/JsignCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void testSigningMultipleFiles() throws Exception {
@Test
public void testSigningMultipleFilesWithListFile() throws Exception {
File listFile = new File("target/test-classes/files.txt");
Files.write(listFile.toPath(), Arrays.asList("# first file", targetFile.getPath(), " ", "# second file", targetFile.getAbsolutePath()));
Files.write(listFile.toPath(), Arrays.asList("# first file", '"' + targetFile.getPath() + '"', " ", "# second file", targetFile.getAbsolutePath()));

cli.execute("--name=WinEyes", "--url=http://www.steelblue.com/WinEyes", "--alg=SHA-1", "--keystore=target/test-classes/keystores/" + keystore, "--keypass=" + keypass, "@" + listFile);

Expand Down

0 comments on commit 46eb00e

Please sign in to comment.