package net.pterodactylus.irc.util;
+import static net.pterodactylus.irc.util.MessageCleaner.Attributes.italics;
+import static net.pterodactylus.irc.util.MessageCleaner.Attributes.reverse;
+import static net.pterodactylus.irc.util.MessageCleaner.Attributes.underline;
+
import java.io.IOException;
import java.io.StringReader;
import java.util.EnumSet;
bold,
color,
- clear
+ clear,
+ reverse,
+ underline,
+ italics
}
if ((c == 15) && (attributes.contains(Attributes.clear))) {
continue;
}
+ if ((c == 22) && attributes.contains(reverse)) {
+ continue;
+ }
+ if ((c == 29) && attributes.contains(italics)) {
+ continue;
+ }
+ if ((c == 31) && attributes.contains(underline)) {
+ continue;
+ }
if (inColorCode > 0) {
if (inColorCode == 1) {
if ((c < '0') || (c > '9')) {
assertThat(clean, is("This contains bold and color and clear characters."));
}
+ @Test
+ public void removeUnderlineFormatting() {
+ MessageCleaner messageCleaner = MessageCleaner.getDefaultInstance();
+ assertThat(messageCleaner.clean("Text\u0016underline"), is("Textunderline"));
+ }
+
+ @Test
+ public void removeReverseFormatting() {
+ MessageCleaner messageCleaner = MessageCleaner.getDefaultInstance();
+ assertThat(messageCleaner.clean("Text\u001freverse"), is("Textreverse"));
+ }
+
+ @Test
+ public void removeItalicFormatting() {
+ MessageCleaner messageCleaner = MessageCleaner.getDefaultInstance();
+ assertThat(messageCleaner.clean("Text\u001ditalics"), is("Textitalics"));
+ }
+
}