Project

General

Profile

Bug #11275 ยป uri-parse-query-pct-encoded.patch

jeremyevans0 (Jeremy Evans), 07/05/2019 10:00 PM

View differences:

lib/uri/generic.rb
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
raise InvalidURIError, "invalid percent escape: #{$1}" if /(%\H\H)/n.match(v)
v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n.freeze){'%%%02X' % $&.ord}
v.force_encoding(Encoding::US_ASCII)
@query = v
test/uri/test_parser.rb
uri_to_ary(u1))
end
def test_parse_query_pct_encoded
assert_equal('q=%32!$&-/?.09;=:@AZ_az~', URI.parse('https://www.example.com/search?q=%32!$&-/?.09;=:@AZ_az~').query)
assert_raise(URI::InvalidURIError) { URI.parse('https://www.example.com/search?q=%XX') }
end
def test_raise_bad_uri_for_integer
assert_raise(URI::InvalidURIError) do
URI.parse(1)
    (1-1/1)