Bug #15979 ยป uri-parse-validate-15979.patch
lib/uri/common.rb | ||
---|---|---|
module URI
|
||
REGEXP = RFC2396_REGEXP
|
||
Parser = RFC2396_Parser
|
||
RFC3986_PARSER = RFC3986_Parser.new
|
||
Parser = RFC3986_Parser
|
||
RFC3986_PARSER = Parser.new
|
||
DEFAULT_PARSER = RFC3986_PARSER
|
||
# URI::Parser.new
|
||
DEFAULT_PARSER = Parser.new
|
||
DEFAULT_PARSER.pattern.each_pair do |sym, str|
|
||
RFC2396_PARSER = RFC2396_Parser.new
|
||
RFC2396_PARSER.pattern.each_pair do |sym, str|
|
||
unless REGEXP::PATTERN.const_defined?(sym)
|
||
REGEXP::PATTERN.const_set(sym, str)
|
||
end
|
||
end
|
||
DEFAULT_PARSER.regexp.each_pair do |sym, str|
|
||
RFC2396_PARSER.regexp.each_pair do |sym, str|
|
||
const_set(sym, str)
|
||
end
|
||
... | ... | |
#
|
||
def self.extract(str, schemes = nil, &block)
|
||
warn "URI.extract is obsolete", uplevel: 1 if $VERBOSE
|
||
DEFAULT_PARSER.extract(str, schemes, &block)
|
||
RFC2396_PARSER.extract(str, schemes, &block)
|
||
end
|
||
#
|
||
... | ... | |
#
|
||
def self.regexp(schemes = nil)
|
||
warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE
|
||
DEFAULT_PARSER.make_regexp(schemes)
|
||
RFC2396_PARSER.make_regexp(schemes)
|
||
end
|
||
TBLENCWWWCOMP_ = {} # :nodoc:
|
lib/uri/generic.rb | ||
---|---|---|
if args.kind_of?(Array)
|
||
return self.build(args.collect{|x|
|
||
if x.is_a?(String)
|
||
DEFAULT_PARSER.escape(x)
|
||
RFC2396_PARSER.escape(x)
|
||
else
|
||
x
|
||
end
|
||
... | ... | |
tmp = {}
|
||
args.each do |key, value|
|
||
tmp[key] = if value
|
||
DEFAULT_PARSER.escape(value)
|
||
RFC2396_PARSER.escape(value)
|
||
else
|
||
value
|
||
end
|
test/uri/test_parser.rb | ||
---|---|---|
def test_parse
|
||
escaped = URI::REGEXP::PATTERN::ESCAPED
|
||
hex = URI::REGEXP::PATTERN::HEX
|
||
p1 = URI::Parser.new(:ESCAPED => "(?:#{escaped}|%u[#{hex}]{4})")
|
||
p1 = URI::RFC2396_Parser.new(:ESCAPED => "(?:#{escaped}|%u[#{hex}]{4})")
|
||
u1 = p1.parse('http://a/b/%uABCD')
|
||
assert_equal(['http', nil, 'a', URI::HTTP.default_port, '/b/%uABCD', nil, nil],
|
||
uri_to_ary(u1))
|
||
... | ... | |
end
|
||
def test_unescape
|
||
p1 = URI::Parser.new
|
||
p1 = URI::RFC2396_Parser.new
|
||
assert_equal("\xe3\x83\x90", p1.unescape("\xe3\x83\x90"))
|
||
assert_equal("\xe3\x83\x90", p1.unescape('%e3%83%90'))
|
||
assert_equal("\u3042", p1.unescape('%e3%81%82'.force_encoding(Encoding::US_ASCII)))
|