Project

General

Profile

Bug #14358 » uri-encode-form-compontent.patch

jeremyevans0 (Jeremy Evans), 06/20/2019 09:49 PM

View differences:

lib/uri/common.rb
if str.encoding != Encoding::ASCII_8BIT
if enc && enc != Encoding::ASCII_8BIT
str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
str.encode!(enc, fallback: ->(x){"&#{x.ord};"})
str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
end
str.force_encoding(Encoding::ASCII_8BIT)
end
test/uri/test_common.rb
"\u3042".encode("sjis"), Encoding::UTF_8))
assert_equal("B0", URI.encode_www_form_component(
"\u3042".encode("sjis"), Encoding::UTF_16LE))
assert_equal("%26%23730%3B", URI.encode_www_form_component(
"\u02DA", Encoding::WINDOWS_1252))
# invalid
assert_equal("%EF%BF%BD%EF%BF%BD", URI.encode_www_form_component(
(2-2/2)