[ISSUE #6747] Add INNER_MULTI_DISPATCH check, can not contains path separator

This commit is contained in:
Humkum
2023-05-16 08:26:17 +08:00
committed by GitHub
parent 8aea26ef8f
commit 5f747f5c24
2 changed files with 12 additions and 0 deletions
@@ -17,13 +17,16 @@
package org.apache.rocketmq.client;
import java.io.File;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.TopicConfig;
import org.apache.rocketmq.common.UtilAll;
import org.apache.rocketmq.common.constant.PermName;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.common.topic.TopicValidator;
import org.apache.rocketmq.remoting.protocol.ResponseCode;
@@ -77,6 +80,12 @@ public class Validators {
throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
"the message body size over max value, MAX: " + defaultMQProducer.getMaxMessageSize());
}
String lmqPath = msg.getUserProperty(MessageConst.PROPERTY_INNER_MULTI_DISPATCH);
if (StringUtils.contains(lmqPath, File.separator)) {
throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,
"INNER_MULTI_DISPATCH " + lmqPath + " can not contains " + File.separator + " character");
}
}
public static void checkTopic(String topic) throws MQClientException {
@@ -749,6 +749,9 @@ public class ConsumeQueue implements ConsumeQueueInterface, FileQueueLifeCycle {
}
for (int i = 0; i < queues.length; i++) {
String queueName = queues[i];
if (StringUtils.contains(queueName, File.separator)) {
continue;
}
long queueOffset = Long.parseLong(queueOffsets[i]);
int queueId = request.getQueueId();
if (this.messageStore.getMessageStoreConfig().isEnableLmq() && MixAll.isLmq(queueName)) {