Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 13D24200C8F for ; Fri, 9 Jun 2017 19:42:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 12792160BCA; Fri, 9 Jun 2017 17:42:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 31AA8160BB6 for ; Fri, 9 Jun 2017 19:42:54 +0200 (CEST) Received: (qmail 95872 invoked by uid 500); 9 Jun 2017 17:42:53 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 95863 invoked by uid 99); 9 Jun 2017 17:42:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jun 2017 17:42:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 45017DFFAB; Fri, 9 Jun 2017 17:42:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jinmeiliao@apache.org To: commits@geode.apache.org Message-Id: <188c6aa1ef924c93a5a61d0124a25618@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: geode git commit: GEODE-3054: escaping the escape character in the command string before passing it to the SimpleParser Date: Fri, 9 Jun 2017 17:42:51 +0000 (UTC) archived-at: Fri, 09 Jun 2017 17:42:55 -0000 Repository: geode Updated Branches: refs/heads/develop 0211029ba -> 2579a0db0 GEODE-3054: escaping the escape character in the command string before passing it to the SimpleParser Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/2579a0db Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/2579a0db Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/2579a0db Branch: refs/heads/develop Commit: 2579a0db0f9e1acad55d3be8dd3a3d5bb33f32d5 Parents: 0211029 Author: Jinmei Liao Authored: Thu Jun 8 11:08:03 2017 -0700 Committer: Jinmei Liao Committed: Fri Jun 9 10:42:03 2017 -0700 ---------------------------------------------------------------------- .../management/internal/cli/GfshParser.java | 2 + .../internal/cli/MultipleValueAdapter.java | 35 ------------- .../internal/cli/MultipleValueConverter.java | 55 -------------------- .../internal/cli/GfshParserParsingTest.java | 29 +++++++++++ 4 files changed, 31 insertions(+), 90 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/2579a0db/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java index df16e9b..b5c24cb 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/GfshParser.java @@ -177,6 +177,8 @@ public class GfshParser extends SimpleParser { public GfshParseResult parse(String userInput) { String rawInput = convertToSimpleParserInput(userInput); + // this tells the simpleParser not to interpret backslash as escaping character + rawInput = rawInput.replace("\\", "\\\\"); // User SimpleParser to parse the input ParseResult result = super.parse(rawInput); http://git-wip-us.apache.org/repos/asf/geode/blob/2579a0db/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueAdapter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueAdapter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueAdapter.java deleted file mode 100644 index 5c466a0..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli; - -import java.util.List; - -import org.springframework.shell.core.Completion; -import org.springframework.shell.core.MethodTarget; - -public abstract class MultipleValueAdapter implements MultipleValueConverter { - - @Override - public T convertFromText(String value, Class targetType, String optionContext) { - return null; - } - - @Override - public boolean getAllPossibleValues(List completions, Class targetType, - String existingData, String optionContext, MethodTarget target) { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/geode/blob/2579a0db/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueConverter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueConverter.java deleted file mode 100644 index e3e1fec..0000000 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/MultipleValueConverter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli; - -import java.util.List; - -import org.springframework.shell.core.Completion; -import org.springframework.shell.core.Converter; -import org.springframework.shell.core.MethodTarget; - -/** - * Extends {@link Converter} to add multiple value support - * - * - * @param - */ -public interface MultipleValueConverter extends Converter { - - /** - * Similar to {@link Converter#convertFromText(String, Class, String)} but with support for - * multiple values - * - * @param value - * @param targetType - * @param context - * @return required Data - */ - T convertFromText(String[] value, Class targetType, String context); - - /** - * Similar to {@link Converter#getAllPossibleValues(List, Class, String, String, MethodTarget)} - * but with support for multiple values - * - * @param completions - * @param targetType - * @param existingData - * @param context - * @param target - * @return required Data - */ - boolean getAllPossibleValues(List completions, Class targetType, - String[] existingData, String context, MethodTarget target); -} http://git-wip-us.apache.org/repos/asf/geode/blob/2579a0db/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java index ab6dc3d..a2efb36 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java @@ -262,4 +262,33 @@ public class GfshParserParsingTest { assertThat(result).isNotNull(); } + + @Test + public void testCommandWithBackSlash() throws Exception { + String command = + "describe offline-disk-store --name=testDiskStore --disk-dirs=R:\\regrResults\\test"; + GfshParseResult result = parser.parse(command); + assertThat(result.getParamValue("disk-dirs")).isEqualTo("R:\\regrResults\\test"); + } + + @Test + public void testCommandWithBackSlashTwo() throws Exception { + String command = "start locator --name=\\test"; + GfshParseResult result = parser.parse(command); + assertThat(result.getParamValue("name")).isEqualTo("\\test"); + } + + @Test + public void testCommandWithBackSlashThree() throws Exception { + String command = "start locator --name=\\myName"; + GfshParseResult result = parser.parse(command); + assertThat(result.getParamValue("name")).isEqualTo("\\myName"); + } + + @Test + public void testCommandWithBackSlashFour() throws Exception { + String command = "start locator --name=\\u0005Name"; + GfshParseResult result = parser.parse(command); + assertThat(result.getParamValue("name")).isEqualTo("\\u0005Name"); + } }