Skip to content

Commit

Permalink
FISH-5974 Allow double quotes in preboot-command file
Browse files Browse the repository at this point in the history
Signed-off-by: JamesHillyard <[email protected]>
  • Loading branch information
JamesHillyard committed Jan 28, 2022
1 parent beb3f53 commit dfbac95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2016-2019] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2016-2022] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -66,12 +66,12 @@ public class BootCommands {

/**
* Command flag pattern include 3 groups to parse the command-line flag
* [^\"']\\S+=[\"'].+?[\"'] e.g --description="results in error"
* [^\"']\\S+=[\"'].+?[\"']\\S* e.g --description="results in error"
* [^\"']\\S+ e.g --enabled=true, --enabled true
* [\"'].+?[\"'] e.g --description "results in error"
* [\"'].+?[\"']\\S* e.g --description "results in error"
*
*/
private static final Pattern COMMAND_FLAG_PATTERN = Pattern.compile("([^\"']\\S+=[\"'].+?[\"']|[^\"']\\S*|[\"'].+?[\"'])\\s*");
private static final Pattern COMMAND_FLAG_PATTERN = Pattern.compile("([^\"']\\S+=[\"'].+?[\"']\\S*|[^\"']\\S*|[\"'].+?[\"']\\S*)\\s*");
private final List<BootCommand> commands;

private static final Logger LOGGER = Logger.getLogger(BootCommands.class.getName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) [2019] Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) [2019-2022] Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -56,7 +56,7 @@ public class BootCommandsTest {
@Test
public void parseCommand() throws IOException {
BootCommands bootCommands = new BootCommands();
String commandText = "create-custom-resource --restype java.lang.String -s v --name='custom-res' --description=\"results in error\" --property value=\"${ENV=ini_ws_uri}\" vfp/vfp-menu/ini.ws.uri";
String commandText = "create-custom-resource --restype java.lang.String -s v --name='custom-res' --description=\"results in \"error\"\" --property value=\"${ENV=ini_ws_uri}\" vfp/vfp-menu/ini.ws.uri";
try (Reader reader = new StringReader(commandText)){
bootCommands.parseCommandScript(reader);
}
Expand All @@ -69,7 +69,7 @@ public void parseCommand() throws IOException {
assertEquals(command.getArguments()[2], "-s");
assertEquals(command.getArguments()[3], "v");
assertEquals(command.getArguments()[4], "--name='custom-res'");
assertEquals(command.getArguments()[5], "--description=\"results in error\"");
assertEquals(command.getArguments()[5], "--description=\"results in \"error\"\"");
assertEquals(command.getArguments()[6], "--property");
assertEquals(command.getArguments()[7], "value=\"${ENV=ini_ws_uri}\"");
assertEquals(command.getArguments()[8], "vfp/vfp-menu/ini.ws.uri");
Expand Down

0 comments on commit dfbac95

Please sign in to comment.