Sha256: df56c888948d3998b930aca83f606a8e041dd4ccccc93d27d766a1b83ae18164

Contents?: true

Size: 869 Bytes

Versions: 14

Compression:

Stored size: 869 Bytes

Contents

# This is a very small part of the CGI class, borrowed from the Rubinius sources
class CGI
  @@accept_charset="UTF-8" unless defined?(@@accept_charset)
  # URL-encode a string.
  #   url_encoded_string = CGI::escape("'Stop!' said Fred")
  #      # => "%27Stop%21%27+said+Fred"
  def CGI::escape(string)
    string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
      '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
    end.tr(' ', '+')
  end

  # URL-decode a string with encoding(optional).
  #   string = CGI::unescape("%27Stop%21%27+said+Fred")
  #      # => "'Stop!' said Fred"
  def CGI::unescape(string,encoding=@@accept_charset)
    str=string.tr('+', ' ').force_encoding(Encoding::ASCII_8BIT).gsub(/((?:%[0-9a-fA-F]{2})+)/) do
      [$1.delete('%')].pack('H*')
    end.force_encoding(encoding)
    str.valid_encoding? ? str : str.force_encoding(string.encoding)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
motion-support-1.2.1 motion/_stdlib/cgi.rb
motion-support-1.1.1 motion/_stdlib/cgi.rb
motion-support-1.2.0 motion/_stdlib/cgi.rb
motion-support-1.1.0 motion/_stdlib/cgi.rb
motion-support-1.0.0 motion/_stdlib/cgi.rb
motion-support-0.3.0 motion/_stdlib/cgi.rb
motion_blender-support-0.2.8 motion/_stdlib/cgi.rb
motion_blender-support-0.2.7 motion/_stdlib/cgi.rb
motion-support-0.2.6 motion/_stdlib/cgi.rb
motion-support-0.2.5 motion/_stdlib/cgi.rb
motion-support-0.2.4 motion/_stdlib/cgi.rb
motion-support-0.2.3 motion/_stdlib/cgi.rb
motion-support-0.2.2 motion/_stdlib/cgi.rb
motion-support-0.2.0 motion/_stdlib/cgi.rb