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

Fix: Trim problem #2149

Merged
merged 1 commit into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
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 @@ -278,7 +278,6 @@ public List<String> getSqls(String sqlStr, boolean isQuery) {
String[] sqls = sqlStr.split(SEMICOLON);
if (sqls.length > 0) {
for (String sql : sqls) {
sql = sql.trim();
boolean select = isQuery(sql);
if (isQuery) {
if (select) {
Expand All @@ -297,11 +296,14 @@ public List<String> getSqls(String sqlStr, boolean isQuery) {
}

private boolean isQuery(String sql) {

sql = sql.trim();

if (sql.toLowerCase().startsWith(SELECT) || sql.toLowerCase().startsWith(WITH)) {
return true;
}

String temp = filterAnnotate(sql);
String temp = filterAnnotate(sql).trim();
return temp.toLowerCase().startsWith(SELECT) || temp.toLowerCase().startsWith(WITH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest

//校验文件是否图片
if (!fileUtils.isImage(file)) {
return resultMap.failAndRefreshToken(request).message("file format error");
return resultMap.failAndRefreshToken(request).message("File format error");
}

//上传文件
Expand All @@ -479,7 +479,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest
try {
avatar = fileUtils.upload(file, Constants.USER_AVATAR_PATH, fileName);
if (StringUtils.isEmpty(avatar)) {
return resultMap.failAndRefreshToken(request).message("user avatar upload error");
return resultMap.failAndRefreshToken(request).message("User avatar upload error");
}
} catch (Exception e) {
log.error("User avatar upload error, username:{}", user.getUsername(), e);
Expand All @@ -500,7 +500,7 @@ public ResultMap uploadAvatar(User user, MultipartFile file, HttpServletRequest
return resultMap.successAndRefreshToken(request).payload(map);
}

return resultMap.failAndRefreshToken(request).message("server error, user avatar update fail");
return resultMap.failAndRefreshToken(request).message("Server error, user avatar update fail");
}


Expand All @@ -518,7 +518,7 @@ public ResultMap getUserProfile(Long id, User user, HttpServletRequest request)

User tempUser = userMapper.getById(id);
if (null == tempUser) {
return resultMap.failAndRefreshToken(request).message("user not found");
return resultMap.failAndRefreshToken(request).message("User not found");
}

UserProfile userProfile = new UserProfile();
Expand Down Expand Up @@ -578,7 +578,7 @@ public String forgetPassword(UserDistinctType userDistinctType, UserDistinctTick
case USERNAME:
String username = ticket.getTicket();
if (StringUtils.isEmpty(username)) {
throw new ServerException("username cannot be EMPTY!");
throw new ServerException("Username cannot be EMPTY!");
}
user = userMapper.selectByUsername(username);
if (user == null) {
Expand Down