You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2016/03/31 23:00:17 UTC

lucene-solr:branch_5_5: SOLR-8725: Allow hyphen in shard, collection, core, and alias names but not the first char (backport to 5.5 branch)

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_5_5 6568d2229 -> 9bca6db03


SOLR-8725: Allow hyphen in shard, collection, core, and alias names but not the first char (backport to 5.5 branch)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/9bca6db0
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/9bca6db0
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/9bca6db0

Branch: refs/heads/branch_5_5
Commit: 9bca6db03223e1da07129e374100b74cc14f9a44
Parents: 6568d22
Author: Anshum Gupta <an...@apache.org>
Authored: Thu Mar 31 12:31:24 2016 -0700
Committer: Anshum Gupta <an...@apache.org>
Committed: Thu Mar 31 12:31:24 2016 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                               | 3 +++
 .../src/java/org/apache/solr/util/SolrIdentifierValidator.java | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9bca6db0/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9eb6c9c..28344f7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -37,6 +37,9 @@ Bug Fixes
 * SOLR-8870: AngularJS Query tab no longer URL-encodes the /select part of the request, fixing possible 404 issue
   when Solr is behind a proxy. Also, now supports old-style &qt param when handler not prefixed with "/" (janhoy)
 
+* SOLR-8725: Allow hyphen in collection, core, shard, and alias name as the non-first character
+  (Anshum Gupta) (from 6.0)
+
 ======================= 5.5.0 =======================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/9bca6db0/solr/core/src/java/org/apache/solr/util/SolrIdentifierValidator.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/util/SolrIdentifierValidator.java b/solr/core/src/java/org/apache/solr/util/SolrIdentifierValidator.java
index dd6133d..3b97f5d 100644
--- a/solr/core/src/java/org/apache/solr/util/SolrIdentifierValidator.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrIdentifierValidator.java
@@ -27,11 +27,11 @@ import org.slf4j.LoggerFactory;
  * Ensures that provided identifiers align with Solr's recommendations/requirements for choosing
  * collection, core, etc identifiers.
  *  
- * Identifiers are allowed to contain underscores, periods, and alphanumeric characters. 
+ * Identifiers are allowed to contain underscores, periods, hyphens, and alphanumeric characters.
  */
 public class SolrIdentifierValidator {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-  final static Pattern identifierPattern = Pattern.compile("^[\\._A-Za-z0-9]*$");
+  final static Pattern identifierPattern = Pattern.compile("^(?!\\-)[\\._A-Za-z0-9\\-]*$");
   
   public static void validateCollectionName(String collectionName) throws SolrException {
     validateCoreName(collectionName);
@@ -41,7 +41,7 @@ public class SolrIdentifierValidator {
     if (name == null || !identifierPattern.matcher(name).matches()) {
       log.info("Validation failed on the invalid identifier [{}].  Throwing SolrException to indicate a BAD REQUEST.", name);
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-          "Invalid name: '" + name + "' Identifiers must consist entirely of periods, underscores and alphanumerics");
+          "Invalid name: '" + name + "' Identifiers must consist entirely of periods, hyphens, underscores and alphanumerics");
     }
   }
 }