diff --git a/spec/std/uri_spec.cr b/spec/std/uri_spec.cr index 7f6650b1c019..935a5927ff7a 100644 --- a/spec/std/uri_spec.cr +++ b/spec/std/uri_spec.cr @@ -121,7 +121,6 @@ describe "URI" do {"hello%252%2Bworld", "hello%2+world"}, {"%E3%81%AA%E3%81%AA", "なな"}, {"%27Stop%21%27%20said%20Fred", "'Stop!' said Fred"}, - {"%FF", String.new(1) { |buf| buf.value = 255_u8; {1, 0} }}, {"%0A", "\n"}, ].each do |tuple| from, to = tuple @@ -136,6 +135,20 @@ describe "URI" do end end + describe "invalid utf8 strings" do + input = String.new(1) { |buf| buf.value = 255_u8; {1, 0} } + + it "escapes without failing" do + URI.escape(input).should eq("%FF") + end + + it "escapes to IO without failing" do + String.build do |str| + URI.escape(input, str) + end.should eq("%FF") + end + end + it "escape space to plus when space_to_plus flag is true" do URI.escape("hello world", space_to_plus: true).should eq("hello+world") URI.escape("'Stop!' said Fred", space_to_plus: true).should eq("%27Stop%21%27+said+Fred")