From dfbac957df4863589b1cfd3cebdf8eb506b470c8 Mon Sep 17 00:00:00 2001 From: JamesHillyard Date: Fri, 28 Jan 2022 17:04:54 +0000 Subject: [PATCH] FISH-5974 Allow double quotes in preboot-command file Signed-off-by: JamesHillyard --- .../main/java/fish/payara/boot/runtime/BootCommands.java | 8 ++++---- .../java/fish/payara/boot/runtime/BootCommandsTest.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nucleus/core/bootstrap/src/main/java/fish/payara/boot/runtime/BootCommands.java b/nucleus/core/bootstrap/src/main/java/fish/payara/boot/runtime/BootCommands.java index a4dfc6b6e07..1e66436368b 100644 --- a/nucleus/core/bootstrap/src/main/java/fish/payara/boot/runtime/BootCommands.java +++ b/nucleus/core/bootstrap/src/main/java/fish/payara/boot/runtime/BootCommands.java @@ -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 @@ -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 commands; private static final Logger LOGGER = Logger.getLogger(BootCommands.class.getName()); diff --git a/nucleus/core/bootstrap/src/test/java/fish/payara/boot/runtime/BootCommandsTest.java b/nucleus/core/bootstrap/src/test/java/fish/payara/boot/runtime/BootCommandsTest.java index d821c58211b..ee8f2cb394c 100644 --- a/nucleus/core/bootstrap/src/test/java/fish/payara/boot/runtime/BootCommandsTest.java +++ b/nucleus/core/bootstrap/src/test/java/fish/payara/boot/runtime/BootCommandsTest.java @@ -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 @@ -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); } @@ -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");