Skip to content

Commit

Permalink
[ISSUE#9323]1.x http接口服务名校验问题 (#9324)
Browse files Browse the repository at this point in the history
* 1.x http接口服务名校验问题

* 1.x http接口服务名校验问题 for #9323
  • Loading branch information
hujun-w-2 authored Oct 14, 2022
1 parent 0bfd752 commit 0834641
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.naming.CommonParams;
import com.alibaba.nacos.api.naming.utils.NamingUtils;
import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.core.utils.OverrideParameterRequestWrapper;
import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.core.utils.OverrideParameterRequestWrapper;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
Expand Down Expand Up @@ -63,6 +64,14 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
if (StringUtils.isNotBlank(serviceName) && !serviceName.contains(Constants.SERVICE_INFO_SPLITER)) {
groupedServiceName = groupName + Constants.SERVICE_INFO_SPLITER + serviceName;
}
if (StringUtils.isNotBlank(groupedServiceName)) {
try {
NamingUtils.checkServiceNameFormat(groupedServiceName);
} catch (IllegalArgumentException e) {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
"Service name filter error," + ExceptionUtil.getAllExceptionMsg(e));
}
}
OverrideParameterRequestWrapper requestWrapper = OverrideParameterRequestWrapper.buildRequest(request);
requestWrapper.addParameter(CommonParams.SERVICE_NAME, groupedServiceName);
filterChain.doFilter(requestWrapper, servletResponse);
Expand Down

1 comment on commit 0834641

@wuchubuzai2018
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个resp之后,是不是得写个return啊

Please sign in to comment.