mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Raise ValueError if color specifier is too long
This commit is contained in:
parent
d5edc5ff09
commit
1dc6564eb7
|
@ -191,3 +191,12 @@ def test_rounding_errors():
|
|||
assert (255, 255) == ImageColor.getcolor("white", "LA")
|
||||
assert (163, 33) == ImageColor.getcolor("rgba(0, 255, 115, 33)", "LA")
|
||||
Image.new("LA", (1, 1), "white")
|
||||
|
||||
|
||||
def test_color_too_long():
|
||||
# Arrange
|
||||
color_too_long = "hsl(" + "1" * 100 + ")"
|
||||
|
||||
# Act / Assert
|
||||
with pytest.raises(ValueError):
|
||||
ImageColor.getrgb(color_too_long)
|
||||
|
|
|
@ -32,6 +32,8 @@ def getrgb(color):
|
|||
:param color: A color string
|
||||
:return: ``(red, green, blue[, alpha])``
|
||||
"""
|
||||
if len(color) > 100:
|
||||
raise ValueError("color specifier is too long")
|
||||
color = color.lower()
|
||||
|
||||
rgb = colormap.get(color, None)
|
||||
|
|
Loading…
Reference in New Issue
Block a user