diff --git a/src/net/java/sip/communicator/impl/protocol/irc/Utils.java b/src/net/java/sip/communicator/impl/protocol/irc/Utils.java
index adea32b56..5c5f6725c 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/Utils.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/Utils.java
@@ -144,6 +144,7 @@ private static Color parseBackgroundColor(final String text)
// if available, also parse background color
int color =
Integer.parseInt("" + text.charAt(1) + text.charAt(2));
+ color = color % Color.values().length;
return Color.values()[color];
}
throw new IllegalArgumentException(
@@ -184,6 +185,7 @@ private static Color parseForegroundColor(final String text)
try
{
int color = Integer.parseInt("" + text.charAt(0) + text.charAt(1));
+ color = color % Color.values().length;
return Color.values()[color];
}
catch (StringIndexOutOfBoundsException e)
@@ -196,7 +198,6 @@ private static Color parseForegroundColor(final String text)
catch (NumberFormatException e)
{
// FIXME correctly print out color code (as a number or hex number)
- // FIXME wrap around color codes?
// Invalid text color value
LOGGER.trace("Invalid foreground color code encountered.");
throw new IllegalArgumentException(
diff --git a/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java b/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
index b9d531712..5ca18a94e 100644
--- a/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
+++ b/test/net/java/sip/communicator/impl/protocol/irc/UtilsTest.java
@@ -143,14 +143,15 @@ public void testParseStringWithUnclosedFormattingI()
public void testParseUnknownForegroundColor()
{
final String ircMessage = "\u000399TEST";
- final String htmlMessage = "99TEST";
+ final String htmlMessage = "TEST";
Assert.assertEquals(htmlMessage, Utils.parse(ircMessage));
}
public void testParseUnknownBackgroundColor()
{
final String ircMessage = "\u000300,99TEST";
- final String htmlMessage = ",99TEST";
+ final String htmlMessage =
+ "TEST";
Assert.assertEquals(htmlMessage, Utils.parse(ircMessage));
}