Sha256: 39cf97e930b964c527daa25c5f764988b7637e0cf54de84c4ab7fcfa5830ce8a

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

require "uri"
if RUBY_VERSION < "2.6.0"
  require "active_support/core_ext/module/redefine_method"
  URI::Parser.class_eval do
    silence_redefinition_of_method :unescape
    def unescape(str, escaped = /%[a-fA-F\d]{2}/)
      # TODO: Are we actually sure that ASCII == UTF-8?
      # YK: My initial experiments say yes, but let's be sure please
      enc = str.encoding
      enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
      str.gsub(escaped) { |match| [match[1, 2].hex].pack("C") }.force_encoding(enc)
    end
  end
end

module URI
  class << self
    def parser
      @parser ||= URI::Parser.new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activesupport-5.2.1.1 lib/active_support/core_ext/uri.rb
activesupport-5.2.1 lib/active_support/core_ext/uri.rb
activesupport-5.2.1.rc1 lib/active_support/core_ext/uri.rb