37敏感字校验

back_recharge
lvxinran 2019-08-21 15:55:47 +08:00
parent 0f783608d2
commit 3312b7993c
5 changed files with 28 additions and 16 deletions

View File

@ -92,7 +92,20 @@ public class ChatLogic {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
FriendManager friendManager = user.getFriendManager();
boolean result = ShieldedWordUtils.checkName(user,message,false);
boolean result = true;
switch (chatType){
case 1:
result = ShieldedWordUtils.checkName(user,message,false,ChatContentType.WORLD_CHAT);
break;
case 2:
result= ShieldedWordUtils.checkName(user,message,false,ChatContentType.FAMILY);
break;
case 3:
result = ShieldedWordUtils.checkName(user,message,false,ChatContentType.PRIVATE_CHAT);
break;
default:
break;
}
if (!result) {
MessageUtil.sendErrorResponse(iSession, 0, msgId, "包含敏感字");
return ;

View File

@ -3,6 +3,7 @@ package com.ljsd.jieling.handler.map;
import com.googlecode.protobuf.format.JsonFormat;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
import com.ljsd.jieling.dataReport.reportBeans_37.Repot37EventUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -3090,7 +3091,7 @@ public class MapLogic {
User user = UserManager.getUser(session.getUid());
MapManager mapManager = user.getMapManager();
if (type == 1) {
boolean result = ShieldedWordUtils.checkName(content, false);
boolean result = ShieldedWordUtils.checkName(user,content, false, ChatContentType.OTHER);
String error;
if (!result) {
error = "输入有敏感字符";

View File

@ -115,12 +115,9 @@ public class GuildLogic {
if(StringUtil.isEmpty(familyName)){
return "名字不能为空";
}
boolean result = ShieldedWordUtils.checkName(familyName,false);
if (!result) {
return "包含敏感字";
}
boolean result = true;
if(!StringUtil.isEmpty(announce)){
result = ShieldedWordUtils.checkName(announce,false);
result = ShieldedWordUtils.checkName(user,announce,false,ChatContentType.FAMILY_NAME);
if (!result) {
return "包含敏感字";
}
@ -559,7 +556,7 @@ public class GuildLogic {
MessageUtil.sendErrorResponse(session, 0, msgId, "包含敏感字");
return;
}
boolean result = ShieldedWordUtils.checkName(content,false);
boolean result = ShieldedWordUtils.checkName(user,content,false,ChatContentType.ANNOUNCE);
int resultCode = 1;
String err = "修改成功";
if (!result) {

View File

@ -150,7 +150,8 @@ public class PlayerLogic {
MessageUtil.sendErrorResponse(iSession, Global.RENAME_SIZE_ERROR, msgId, "名字长度不符!");
return true;
}
boolean result = ShieldedWordUtils.checkName( name,true);
;
boolean result = ShieldedWordUtils.checkName(UserManager.getUser(iSession.getUid()),name,true,ChatContentType.ROLE_NAME);
if (!result) {
MessageUtil.sendErrorResponse(iSession, Global.RENAME_DIRTY, msgId, "名字不合法");
return true;

View File

@ -9,7 +9,13 @@ import java.util.regex.Pattern;
public class ShieldedWordUtils {
public static boolean checkName(String name,boolean validateSpecStr){
// public static boolean checkName(String name,boolean validateSpecStr){
//
// }
public static boolean checkName(User user , String name,boolean validateSpecStr,ChatContentType chatContentType){
if(!Repot37EventUtil.Report37Chat(user, ChatContentType.WORLD_CHAT.getType(),name)){
return false;
}
boolean result = true;
if(validateSpecStr){
result = validateUserName(name);
@ -24,12 +30,6 @@ public class ShieldedWordUtils {
}
return true;
}
public static boolean checkName(User user , String name,boolean validateSpecStr){
if(!Repot37EventUtil.Report37Chat(user, ChatContentType.WORLD_CHAT.getType(),name)){
return false;
}
return checkName(name,validateSpecStr);
}
/**