Project

General

Profile

Bug #10619 ยป 0001-use-the-parser-type-to-escape-the-query-string.patch

tenderlovemaking (Aaron Patterson), 12/18/2014 08:01 PM

View differences:

lib/uri/generic.rb
v.encode!(Encoding::UTF_8) rescue nil
v.delete!("\t\r\n")
v.force_encoding(Encoding::ASCII_8BIT)
v.gsub!(/(?!%\h\h|[!$-&(-;=?-Z_a-~])./n.freeze){'%%%02X'.freeze % $&.ord}
v = parser.escape_query v
v.force_encoding(Encoding::US_ASCII)
@query = v
end
lib/uri/rfc2396_parser.rb
@@to_s.bind(self).call
end
# Escapes query strings for RFC2396 uris
def escape_query(v) # :nodoc:
v.gsub!(/(?!%\h\h|[!$-&(-;=?-_a-~])./n){'%%%02X' % $&.ord}
v
end
private
# Constructs the default Hash of patterns
lib/uri/rfc3986_parser.rb
}
end
# Escapes query strings for RFC2396 uris
def escape_query(v) # :nodoc:
v.gsub!(/(?!%\h\h|[!$-&(-;=?-Z_a-~])./n.freeze){'%%%02X'.freeze % $&.ord}
v
end
private
def convert_to_uri(uri)
test/uri/test_rfc2396.rb
require 'test/unit'
require 'uri'
module URI
class TestRFC2396 < Test::Unit::TestCase
def test_query_on_parse
parser = URI::RFC2396_Parser.new
uri = parser.parse "http://www.example.com/parse?location[]=1"
assert_equal 'location[]=1', uri.query
end
end
end
    (1-1/1)