Skip to content

Commit

Permalink
Fix: specs for URI.escape where using unsafe strings as example names
Browse files Browse the repository at this point in the history
This caused an error in a JUnitFormatter, which was assuming the spec name was a valid string.
  • Loading branch information
juanedi committed Apr 14, 2016
1 parent 935ed64 commit a14eb02
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spec/std/uri_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit a14eb02

Please sign in to comment.