Project

General

Profile

Bug #1787 » lib_uri_common.patch

drry (drry  ), 07/19/2009 01:24 AM

View differences:

lib/uri/common.rb (working copy)
# alpha = lowalpha | upalpha
ALPHA = "a-zA-Z"
# digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | 7" |
# "8" | "9"
DIGIT = "0-9"
# alphanum = alpha | digit
ALNUM = "#{ALPHA}\\d"
ALNUM = "#{ALPHA}#{DIGIT}"
# hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
# "a" | "b" | "c" | "d" | "e" | "f"
HEX = "a-fA-F\\d"
HEX = "#{DIGIT}a-fA-F"
# escaped = "%" hex hex
ESCAPED = "%[#{HEX}]{2}"
# mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
......
# allowed too. Here is a replacement.
#
# IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
ret[:IPV4ADDR] = ipv4addr = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
v4digit = "#{PATTERN::DIGIT}{1,3}"
ipv4addr = "(?:#{v4digit}\\.){3}#{v4digit}"
ret[:IPV4ADDR] = ipv4addr
# hex4 = 1*4HEXDIG
hex4 = "[#{PATTERN::HEX}]{1,4}"
# lastpart = hex4 | IPv4address
......
# host = hostname | IPv4address | IPv6reference (RFC 2732)
ret[:HOST] = host = "(?:#{hostname}|#{ipv4addr}|#{ipv6ref})"
# port = *digit
port = '\d*'
port = '[#{PATTERN::DIGIT}]*'
# hostport = host [ ":" port ]
ret[:HOSTPORT] = hostport = "#{host}(?::#{port})?"
......
ret[:REL_SEGMENT] = rel_segment = "(?:[#{unreserved};@&=+$,]|#{escaped})+"
# scheme = alpha *( alpha | digit | "+" | "-" | "." )
ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][-+.#{PATTERN::ALPHA}\\d]*"
ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][-+.#{PATTERN::ALPHA}#{PATTERN::DIGIT}]*"
# abs_path = "/" path_segments
ret[:ABS_PATH] = abs_path = "/#{path_segments}"
......
(?:(?:
//(?:
(?:(?:(#{userinfo})@)? (?# 3: userinfo)
(?:(#{host})(?::(\\d*))?))? (?# 4: host, 5: port)
(?:(#{host}) (?# 4: host)
(?::([#{PATTERN::DIGIT}]*))?))? (?# 5: port)
|
(#{reg_name}) (?# 6: registry)
)
......
//
(?:
(?:(#{userinfo})@)? (?# 1: userinfo)
(#{host})?(?::(\\d*))? (?# 2: host, 3: port)
(#{host})? (?# 2: host)
(?::([#{PATTERN::DIGIT}]*))? (?# 3: port)
|
(#{reg_name}) (?# 4: registry)
)
(3-3/6)