You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2016/04/27 20:22:20 UTC
[36/50] [abbrv] lucene-solr:solr-5750: SOLR-9016: Fix
SolrIdentifierValidator to not accept empty identifiers
SOLR-9016: Fix SolrIdentifierValidator to not accept empty identifiers
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/91666479
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/91666479
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/91666479
Branch: refs/heads/solr-5750
Commit: 9166647918d26fd75ae48d993e9191ad8d943fe3
Parents: 9d8fad7
Author: Shai Erera <sh...@apache.org>
Authored: Tue Apr 26 17:28:04 2016 +0300
Committer: Shai Erera <sh...@apache.org>
Committed: Tue Apr 26 18:20:47 2016 +0300
----------------------------------------------------------------------
solr/CHANGES.txt | 2 ++
.../solr/client/solrj/util/SolrIdentifierValidator.java | 12 +++++-------
2 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91666479/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 101cdfd..4baea2c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -154,6 +154,8 @@ Bug Fixes
* SOLR-9029: fix rare ZkStateReader visibility race during collection state format update (Scott Blum, hossman)
+* SOLR-9016: Fix SolrIdentifierValidator to not allow empty identifiers. (Shai Erera)
+
Optimizations
----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/91666479/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
index 9473a28..d23b8bb 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/util/SolrIdentifierValidator.java
@@ -28,7 +28,7 @@ import org.apache.solr.common.SolrException;
* Identifiers are allowed to contain underscores, periods, hyphens, and alphanumeric characters.
*/
public class SolrIdentifierValidator {
- final static Pattern identifierPattern = Pattern.compile("^(?!\\-)[\\._A-Za-z0-9\\-]*$");
+ final static Pattern identifierPattern = Pattern.compile("^(?!\\-)[\\._A-Za-z0-9\\-]+$");
public enum IdentifierType {
SHARD, COLLECTION, CORE, ALIAS
@@ -64,11 +64,9 @@ public class SolrIdentifierValidator {
}
public static String getIdentifierMessage(IdentifierType identifierType, String name) {
- return "Invalid " + identifierType.toString().toLowerCase(Locale.ROOT) + ": " + name + ". "
- + identifierType.toString().toLowerCase(Locale.ROOT)
- + " names must consist entirely of periods, underscores, hyphens, and alphanumerics";
-
+ String typeStr = identifierType.toString().toLowerCase(Locale.ROOT);
+ return "Invalid " + typeStr + ": [" + name + "]. " + typeStr + " names must consist entirely of periods, "
+ + "underscores, hyphens, and alphanumerics as well not start with a hyphen";
}
-}
-
+}