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
370 370
    if str.encoding != Encoding::ASCII_8BIT
371 371
      if enc && enc != Encoding::ASCII_8BIT
372 372
        str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
373
        str.encode!(enc, fallback: ->(x){"&#{x.ord};"})
373
        str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
374 374
      end
375 375
      str.force_encoding(Encoding::ASCII_8BIT)
376 376
    end
test/uri/test_common.rb
81 81
                   "\u3042".encode("sjis"), Encoding::UTF_8))
82 82
    assert_equal("B0", URI.encode_www_form_component(
83 83
                   "\u3042".encode("sjis"), Encoding::UTF_16LE))
84
    assert_equal("%26%23730%3B", URI.encode_www_form_component(
85
                   "\u02DA", Encoding::WINDOWS_1252))
84 86

  
85 87
    # invalid
86 88
    assert_equal("%EF%BF%BD%EF%BF%BD", URI.encode_www_form_component(
87
-