Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:增加手动注册的HTTP地址有效性校验 #3563

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public Map<String, Object> pageList(HttpServletRequest request,
@RequestParam(required = false, defaultValue = "0") int start,
@RequestParam(required = false, defaultValue = "10") int length,
String appname, String title) {

// page query
List<XxlJobGroup> list = xxlJobGroupDao.pageList(start, length, appname, title);
int list_count = xxlJobGroupDao.pageListCount(start, length, appname, title);
Expand Down Expand Up @@ -141,6 +140,10 @@ public ReturnT<String> update(XxlJobGroup xxlJobGroup){
if (item==null || item.trim().length()==0) {
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
}
String url = item.trim().toLowerCase();
if (!isHttpAddressValid(url)){
return new ReturnT<String>(500, I18nUtil.getString("jobgroup_field_registryList_unvalid") );
}
}
}

Expand All @@ -151,6 +154,19 @@ public ReturnT<String> update(XxlJobGroup xxlJobGroup){
return (ret>0)?ReturnT.SUCCESS:ReturnT.FAIL;
}

// valid http address
private boolean isHttpAddressValid(String url){
if (url == null){
return false;
}

// valid
if(!url.startsWith("http://") && !url.startsWith("https://") && url.contains(" ")){
return false;
}
return true;
}

private List<String> findRegistryByAppName(String appnameParam){
HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
Expand Down