diff --git a/lib/prawn/graphics/color.rb b/lib/prawn/graphics/color.rb index e22886564..cebcdf7a6 100644 --- a/lib/prawn/graphics/color.rb +++ b/lib/prawn/graphics/color.rb @@ -94,7 +94,7 @@ def process_color(*color) def color_type(color) case color when String - if color =~ /\A[0-F]{6}\z/i + if color =~ /\A[0-9|A-F]{6}\z/i :RGB else raise ArgumentError, "Unknown type of color: #{color.inspect}" diff --git a/spec/prawn/graphics_spec.rb b/spec/prawn/graphics_spec.rb index db9c878d7..827c8a0c5 100644 --- a/spec/prawn/graphics_spec.rb +++ b/spec/prawn/graphics_spec.rb @@ -245,6 +245,10 @@ expect { pdf.fill_color 'zcff00' }.to raise_error(ArgumentError) end + it 'raises an error for a color string with invalid characters' do + expect { pdf.fill_color 'f0f0f?' }.to raise_error(ArgumentError) + end + it 'resets the colors on each new page if they have been defined' do pdf.fill_color 'ccff00'