mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-31 16:07:30 +03:00 
			
		
		
		
	Raise ValueError if color specifier is too long
This commit is contained in:
		
							parent
							
								
									bd5cf7db87
								
							
						
					
					
						commit
						9e08eb8f78
					
				|  | @ -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