Skip to content

Commit

Permalink
ACCUMULO-4756 Small regex fixes for validating names
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ctubbsii committed Dec 15, 2017
1 parent 0d177a0 commit 4459496
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -213,7 +213,8 @@ public TablesList getTableWithNamespace(@PathParam("namespaces") @NotNull @Patte
*/
@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);

Expand Down
Expand Up @@ -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 + ")*";
}

0 comments on commit 4459496

Please sign in to comment.