You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2017/12/15 02:33:01 UTC

[accumulo] branch master updated: ACCUMULO-4756 Small regex fixes for validating names

This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new 4459496  ACCUMULO-4756 Small regex fixes for validating names
4459496 is described below

commit 44594962e9f14f98507a540d7be650425ca2beac
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Dec 14 21:25:22 2017 -0500

    ACCUMULO-4756 Small regex fixes for validating names
    
    Fix a few small regex issues with namespace and table name validation.
    This fix allows the default namespace to be specified in the
    comma-separated list of namespaces, along with other namespaces.
    
    Also apply minor regex cleanup by removing unnecessary parens, applying
    constraints on the number of digits in a port for server:port, and
    deduplicating the server regex for the case where it is optional.
    
    Also apply previously uncommitted formatting changes.
---
 .../apache/accumulo/monitor/rest/tables/TablesResource.java  |  3 ++-
 .../org/apache/accumulo/monitor/util/ParameterValidator.java | 12 ++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
index 19c9ac4..479b7f7 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
@@ -213,7 +213,8 @@ public class TablesResource {
    */
   @Path("{tableId}")
   @GET
-  public TabletServers getParticipatingTabletServers(@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableIdStr) throws Exception {
+  public TabletServers getParticipatingTabletServers(@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableIdStr)
+      throws Exception {
     Instance instance = Monitor.getContext().getInstance();
     Table.ID tableId = Table.ID.of(tableIdStr);
 
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/ParameterValidator.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/ParameterValidator.java
index aec0826..c9b29d0 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/util/ParameterValidator.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/util/ParameterValidator.java
@@ -28,9 +28,13 @@ public interface ParameterValidator {
 
   String RESOURCE_REGEX = "(\\w|:)+";
 
-  String NAMESPACE_REGEX = "[*-]?|(\\w)+";
-  String NAMESPACE_LIST_REGEX = "[*-]?|(\\w+,?\\w*)+";
+  // asterisk or - or blank or a namespace name
+  String NAMESPACE_REGEX = "[*-]?|\\w+";
 
-  String SERVER_REGEX = "(\\w+([.-])*\\w*)+(:[0-9]+)*";
-  String SERVER_REGEX_BLANK_OK = "((\\w+([.-])*\\w*)+(:[0-9]+)*)*";
+  // asterisk or blank or a comma-separated list of - or namespace names (optional trailing comma)
+  String NAMESPACE_LIST_REGEX = "[*]?|([-]|\\w+)(,([-]|\\w+))*,?";
+
+  // host name and port
+  String SERVER_REGEX = "(\\w+[.-]*\\w*)+(:[0-9]{1,5})*";
+  String SERVER_REGEX_BLANK_OK = "(" + SERVER_REGEX + ")*";
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@accumulo.apache.org" <co...@accumulo.apache.org>'].