lhotari commented on code in PR #25304:
URL: https://github.com/apache/pulsar/pull/25304#discussion_r2927053919
##########
pulsar-websocket/src/main/java/org/apache/pulsar/websocket/AbstractWebSocketHandler.java:
##########
@@ -271,28 +263,15 @@ protected void extractTopicName(HttpServletRequest
request) {
checkArgument(parts.size() >= 8, "Invalid topic name format");
checkArgument(parts.get(1).equals("ws"));
+ checkArgument(parts.get(2).equals("v2"));
- final boolean isV2Format = parts.get(2).equals("v2");
- final int domainIndex = isV2Format ? 4 : 3;
- checkArgument(parts.get(domainIndex).equals("persistent")
- || parts.get(domainIndex).equals("non-persistent"));
+ checkArgument(parts.get(4).equals("persistent")
+ || parts.get(4).equals("non-persistent"));
- final String domain = parts.get(domainIndex);
- final NamespaceName namespace = isV2Format ?
NamespaceName.get(parts.get(5), parts.get(6)) :
- NamespaceName.get(parts.get(4), parts.get(5), parts.get(6));
+ final String domain = parts.get(4);
+ final NamespaceName namespace = NamespaceName.get(parts.get(5),
parts.get(6));
- // The topic name which contains slashes is also split, so it needs to
be jointed
- int startPosition = 7;
- boolean isConsumer = "consumer".equals(parts.get(2)) ||
"consumer".equals(parts.get(3));
- int endPosition = isConsumer ? parts.size() - 1 : parts.size();
- StringBuilder topicName = new StringBuilder(parts.get(startPosition));
- while (++startPosition < endPosition) {
- if (StringUtils.isEmpty(parts.get(startPosition))) {
- continue;
- }
- topicName.append("/").append(parts.get(startPosition));
- }
- final String name = Codec.decode(topicName.toString());
+ final String name = Codec.decode(parts.get(7));
Review Comment:
What has happened in the past is that if a user accidentially used a topic
name with a slash, it became a v1 topic name accidentially. In v1 topics, the
missing cluster, tenant and namespace get created automatically when they are
missing. #23620 was added to prevent this from happening.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]