preventing regex injection
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package network.protocol;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ANSIColor {
|
||||
public static final String RESET = "\u001B[0m";
|
||||
public static final String BLACK = "\u001B[30m";
|
||||
@@ -17,6 +19,6 @@ public class ANSIColor {
|
||||
}
|
||||
|
||||
public static String tag(String message, String chatter){
|
||||
return message.replaceAll("(@" + chatter + ")", "\u001B[44;30m$1\u001B[49;39m" );
|
||||
return message.replaceAll("(@" + Pattern.quote(chatter) + ")", "\u001B[44;30m$1\u001B[49;39m" );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user