mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix fallback in URI.encode_www_form_component to include #
Patch from Matthew Kerwin. Fixes [Bug #14358]
This commit is contained in:
parent
43a16c98df
commit
a2c26fe1c6
Notes:
git
2019-09-27 23:44:02 +09:00
2 changed files with 3 additions and 1 deletions
|
@ -370,7 +370,7 @@ module URI
|
|||
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
|
||||
|
|
|
@ -82,6 +82,8 @@ class TestCommon < Test::Unit::TestCase
|
|||
"\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(
|
||||
|
|
Loading…
Add table
Reference in a new issue