Skip to content

Commit 2a0c59a

Browse files
erobotRobertIndie
authored andcommitted
Fix NamedEntity::checkName regression (#127)
1 parent a9f3ced commit 2a0c59a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

lib/NamedEntity.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* Allowed characters for property, namespace, cluster and topic names are
25-
* alphanumeric (a-zA-Z_0-9) and these special chars -=:.
25+
* alphanumeric (a-zA-Z0-9) and these special chars _-=:.
2626
* @param name
2727
* @return
2828
*/
@@ -33,6 +33,7 @@ bool NamedEntity::checkName(const std::string& name) {
3333
}
3434

3535
switch (c) {
36+
case '_':
3637
case '-':
3738
case '=':
3839
case ':':

tests/NamespaceNameTest.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ TEST(NamespaceNameTest, testNamespaceNameV2) {
4444
}
4545

4646
TEST(NamespaceNameTest, testNamespaceNameLegalCharacters) {
47-
std::shared_ptr<NamespaceName> nn1 = NamespaceName::get("cluster-1:=.", "namespace-1:=.");
48-
ASSERT_EQ("cluster-1:=.", nn1->getProperty());
47+
std::shared_ptr<NamespaceName> nn1 = NamespaceName::get("cluster-1:=._", "namespace-1:=._");
48+
ASSERT_TRUE(nn1);
49+
ASSERT_EQ("cluster-1:=._", nn1->getProperty());
4950
ASSERT_TRUE(nn1->getCluster().empty());
50-
ASSERT_EQ("namespace-1:=.", nn1->getLocalName());
51+
ASSERT_EQ("namespace-1:=._", nn1->getLocalName());
5152
ASSERT_TRUE(nn1->isV2());
5253
}

tests/TopicNameTest.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,13 @@ TEST(TopicNameTest, testIllegalCharacters) {
143143
}
144144

145145
TEST(TopicNameTest, testLegalNonAlphaCharacters) {
146-
std::shared_ptr<TopicName> topicName = TopicName::get("persistent://cluster-1:=./namespace-1:=./topic");
146+
std::shared_ptr<TopicName> topicName =
147+
TopicName::get("persistent://cluster-1:=._/namespace-1:=._/topic_");
147148
ASSERT_TRUE(topicName);
148-
ASSERT_EQ("cluster-1:=.", topicName->getProperty());
149-
ASSERT_EQ("namespace-1:=.", topicName->getNamespacePortion());
149+
ASSERT_EQ("cluster-1:=._", topicName->getProperty());
150+
ASSERT_EQ("namespace-1:=._", topicName->getNamespacePortion());
150151
ASSERT_EQ("persistent", topicName->getDomain());
151-
ASSERT_EQ("topic", topicName->getLocalName());
152+
ASSERT_EQ("topic_", topicName->getLocalName());
152153
}
153154

154155
TEST(TopicNameTest, testIllegalUrl) {

0 commit comments

Comments
 (0)