Skip to content

Commit d49afc6

Browse files
author
Dmitry Radchuk
committed
Fix rgba alpha channel parsing
DEVSIX-2673
1 parent 07a241a commit d49afc6

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

kernel/src/main/java/com/itextpdf/kernel/colors/WebColors.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ public static float[] getRGBAColor(String name) {
301301
parseRGBColors(color, tok);
302302
if (tok.hasMoreTokens()) {
303303
color[3] = getAlphaChannelValue(tok.nextToken());
304+
if (tok.hasMoreTokens()) {
305+
throw new IllegalArgumentException("Too many arguments");
306+
}
304307
}
305308
} else if (NAMES.containsKey(colorName)) {
306309
int[] intColor = NAMES.get(colorName);

kernel/src/test/java/com/itextpdf/kernel/colors/WebColorsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ public void getRGBAColorWithExceptionDuringParsing() {
204204
Assertions.assertNull(resultCmyk);
205205
}
206206

207+
@Test
208+
public void getRGBAColorWithExceptionDuringParsingAlpha() {
209+
float[] resultCmyk = WebColors.getRGBAColor("rgba(44, 100, 0, 0,75)");
210+
Assertions.assertNull(resultCmyk);
211+
}
207212

208213

209214
@Test

svg/src/test/java/com/itextpdf/svg/renderers/OpacityTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public void testOpacityComplex() throws IOException, InterruptedException {
5757
}
5858

5959
@Test
60-
//TODO: update after DEVSIX-2673 fix
6160
public void testRGBA() throws IOException, InterruptedException {
6261
convertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "svg_rgba");
6362
}
Binary file not shown.

0 commit comments

Comments
 (0)