Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/uri
File: rfc3986_parser.rb
# frozen_string_literal: false
[0] Fix | Delete
module URI
[1] Fix | Delete
class RFC3986_Parser # :nodoc:
[2] Fix | Delete
# URI defined in RFC3986
[3] Fix | Delete
# this regexp is modified not to host is not empty string
[4] Fix | Delete
RFC3986_URI = /\A(?<URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*+):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
[5] Fix | Delete
RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*+)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h++\.[!$&-.0-;=A-Z_a-z~]++))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])++))?(?::(?<port>\d*+))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*+))*+)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])++)(?:\/\g<segment>)*+)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])++)(?:\/\g<segment>)*+)|(?<path-empty>))(?:\?(?<query>[^#]*+))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*+))?)\z/
[6] Fix | Delete
attr_reader :regexp
[7] Fix | Delete
[8] Fix | Delete
def initialize
[9] Fix | Delete
@regexp = default_regexp.each_value(&:freeze).freeze
[10] Fix | Delete
end
[11] Fix | Delete
[12] Fix | Delete
def split(uri) #:nodoc:
[13] Fix | Delete
begin
[14] Fix | Delete
uri = uri.to_str
[15] Fix | Delete
rescue NoMethodError
[16] Fix | Delete
raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
[17] Fix | Delete
end
[18] Fix | Delete
uri.ascii_only? or
[19] Fix | Delete
raise InvalidURIError, "URI must be ascii only #{uri.dump}"
[20] Fix | Delete
if m = RFC3986_URI.match(uri)
[21] Fix | Delete
query = m["query".freeze]
[22] Fix | Delete
scheme = m["scheme".freeze]
[23] Fix | Delete
opaque = m["path-rootless".freeze]
[24] Fix | Delete
if opaque
[25] Fix | Delete
opaque << "?#{query}" if query
[26] Fix | Delete
[ scheme,
[27] Fix | Delete
nil, # userinfo
[28] Fix | Delete
nil, # host
[29] Fix | Delete
nil, # port
[30] Fix | Delete
nil, # registry
[31] Fix | Delete
nil, # path
[32] Fix | Delete
opaque,
[33] Fix | Delete
nil, # query
[34] Fix | Delete
m["fragment".freeze]
[35] Fix | Delete
]
[36] Fix | Delete
else # normal
[37] Fix | Delete
[ scheme,
[38] Fix | Delete
m["userinfo".freeze],
[39] Fix | Delete
m["host".freeze],
[40] Fix | Delete
m["port".freeze],
[41] Fix | Delete
nil, # registry
[42] Fix | Delete
(m["path-abempty".freeze] ||
[43] Fix | Delete
m["path-absolute".freeze] ||
[44] Fix | Delete
m["path-empty".freeze]),
[45] Fix | Delete
nil, # opaque
[46] Fix | Delete
query,
[47] Fix | Delete
m["fragment".freeze]
[48] Fix | Delete
]
[49] Fix | Delete
end
[50] Fix | Delete
elsif m = RFC3986_relative_ref.match(uri)
[51] Fix | Delete
[ nil, # scheme
[52] Fix | Delete
m["userinfo".freeze],
[53] Fix | Delete
m["host".freeze],
[54] Fix | Delete
m["port".freeze],
[55] Fix | Delete
nil, # registry,
[56] Fix | Delete
(m["path-abempty".freeze] ||
[57] Fix | Delete
m["path-absolute".freeze] ||
[58] Fix | Delete
m["path-noscheme".freeze] ||
[59] Fix | Delete
m["path-empty".freeze]),
[60] Fix | Delete
nil, # opaque
[61] Fix | Delete
m["query".freeze],
[62] Fix | Delete
m["fragment".freeze]
[63] Fix | Delete
]
[64] Fix | Delete
else
[65] Fix | Delete
raise InvalidURIError, "bad URI(is not URI?): #{uri.inspect}"
[66] Fix | Delete
end
[67] Fix | Delete
end
[68] Fix | Delete
[69] Fix | Delete
def parse(uri) # :nodoc:
[70] Fix | Delete
scheme, userinfo, host, port,
[71] Fix | Delete
registry, path, opaque, query, fragment = self.split(uri)
[72] Fix | Delete
scheme_list = URI.scheme_list
[73] Fix | Delete
if scheme && scheme_list.include?(uc = scheme.upcase)
[74] Fix | Delete
scheme_list[uc].new(scheme, userinfo, host, port,
[75] Fix | Delete
registry, path, opaque, query,
[76] Fix | Delete
fragment, self)
[77] Fix | Delete
else
[78] Fix | Delete
Generic.new(scheme, userinfo, host, port,
[79] Fix | Delete
registry, path, opaque, query,
[80] Fix | Delete
fragment, self)
[81] Fix | Delete
end
[82] Fix | Delete
end
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
def join(*uris) # :nodoc:
[86] Fix | Delete
uris[0] = convert_to_uri(uris[0])
[87] Fix | Delete
uris.inject :merge
[88] Fix | Delete
end
[89] Fix | Delete
[90] Fix | Delete
@@to_s = Kernel.instance_method(:to_s)
[91] Fix | Delete
def inspect
[92] Fix | Delete
@@to_s.bind_call(self)
[93] Fix | Delete
end
[94] Fix | Delete
[95] Fix | Delete
private
[96] Fix | Delete
[97] Fix | Delete
def default_regexp # :nodoc:
[98] Fix | Delete
{
[99] Fix | Delete
SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
[100] Fix | Delete
USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
[101] Fix | Delete
HOST: /\A(?:(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{,4}::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))\z/,
[102] Fix | Delete
ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
[103] Fix | Delete
REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
[104] Fix | Delete
QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
[105] Fix | Delete
FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
[106] Fix | Delete
OPAQUE: /\A(?:[^\/].*)?\z/,
[107] Fix | Delete
PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
[108] Fix | Delete
}
[109] Fix | Delete
end
[110] Fix | Delete
[111] Fix | Delete
def convert_to_uri(uri)
[112] Fix | Delete
if uri.is_a?(URI::Generic)
[113] Fix | Delete
uri
[114] Fix | Delete
elsif uri = String.try_convert(uri)
[115] Fix | Delete
parse(uri)
[116] Fix | Delete
else
[117] Fix | Delete
raise ArgumentError,
[118] Fix | Delete
"bad argument (expected URI object or URI string)"
[119] Fix | Delete
end
[120] Fix | Delete
end
[121] Fix | Delete
[122] Fix | Delete
end # class Parser
[123] Fix | Delete
end # module URI
[124] Fix | Delete
[125] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function