Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/uri
File: rfc2396_parser.rb
# frozen_string_literal: false
[0] Fix | Delete
#--
[1] Fix | Delete
# = uri/common.rb
[2] Fix | Delete
#
[3] Fix | Delete
# Author:: Akira Yamada <akira@ruby-lang.org>
[4] Fix | Delete
# Revision:: $Id$
[5] Fix | Delete
# License::
[6] Fix | Delete
# You can redistribute it and/or modify it under the same term as Ruby.
[7] Fix | Delete
#
[8] Fix | Delete
# See URI for general documentation
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
module URI
[12] Fix | Delete
#
[13] Fix | Delete
# Includes URI::REGEXP::PATTERN
[14] Fix | Delete
#
[15] Fix | Delete
module RFC2396_REGEXP
[16] Fix | Delete
#
[17] Fix | Delete
# Patterns used to parse URI's
[18] Fix | Delete
#
[19] Fix | Delete
module PATTERN
[20] Fix | Delete
# :stopdoc:
[21] Fix | Delete
[22] Fix | Delete
# RFC 2396 (URI Generic Syntax)
[23] Fix | Delete
# RFC 2732 (IPv6 Literal Addresses in URL's)
[24] Fix | Delete
# RFC 2373 (IPv6 Addressing Architecture)
[25] Fix | Delete
[26] Fix | Delete
# alpha = lowalpha | upalpha
[27] Fix | Delete
ALPHA = "a-zA-Z"
[28] Fix | Delete
# alphanum = alpha | digit
[29] Fix | Delete
ALNUM = "#{ALPHA}\\d"
[30] Fix | Delete
[31] Fix | Delete
# hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
[32] Fix | Delete
# "a" | "b" | "c" | "d" | "e" | "f"
[33] Fix | Delete
HEX = "a-fA-F\\d"
[34] Fix | Delete
# escaped = "%" hex hex
[35] Fix | Delete
ESCAPED = "%[#{HEX}]{2}"
[36] Fix | Delete
# mark = "-" | "_" | "." | "!" | "~" | "*" | "'" |
[37] Fix | Delete
# "(" | ")"
[38] Fix | Delete
# unreserved = alphanum | mark
[39] Fix | Delete
UNRESERVED = "\\-_.!~*'()#{ALNUM}"
[40] Fix | Delete
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
[41] Fix | Delete
# "$" | ","
[42] Fix | Delete
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
[43] Fix | Delete
# "$" | "," | "[" | "]" (RFC 2732)
[44] Fix | Delete
RESERVED = ";/?:@&=+$,\\[\\]"
[45] Fix | Delete
[46] Fix | Delete
# domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
[47] Fix | Delete
DOMLABEL = "(?:[#{ALNUM}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
[48] Fix | Delete
# toplabel = alpha | alpha *( alphanum | "-" ) alphanum
[49] Fix | Delete
TOPLABEL = "(?:[#{ALPHA}](?:[-#{ALNUM}]*[#{ALNUM}])?)"
[50] Fix | Delete
# hostname = *( domainlabel "." ) toplabel [ "." ]
[51] Fix | Delete
HOSTNAME = "(?:#{DOMLABEL}\\.)*#{TOPLABEL}\\.?"
[52] Fix | Delete
[53] Fix | Delete
# :startdoc:
[54] Fix | Delete
end # PATTERN
[55] Fix | Delete
[56] Fix | Delete
# :startdoc:
[57] Fix | Delete
end # REGEXP
[58] Fix | Delete
[59] Fix | Delete
# Class that parses String's into URI's.
[60] Fix | Delete
#
[61] Fix | Delete
# It contains a Hash set of patterns and Regexp's that match and validate.
[62] Fix | Delete
#
[63] Fix | Delete
class RFC2396_Parser
[64] Fix | Delete
include RFC2396_REGEXP
[65] Fix | Delete
[66] Fix | Delete
#
[67] Fix | Delete
# == Synopsis
[68] Fix | Delete
#
[69] Fix | Delete
# URI::Parser.new([opts])
[70] Fix | Delete
#
[71] Fix | Delete
# == Args
[72] Fix | Delete
#
[73] Fix | Delete
# The constructor accepts a hash as options for parser.
[74] Fix | Delete
# Keys of options are pattern names of URI components
[75] Fix | Delete
# and values of options are pattern strings.
[76] Fix | Delete
# The constructor generates set of regexps for parsing URIs.
[77] Fix | Delete
#
[78] Fix | Delete
# You can use the following keys:
[79] Fix | Delete
#
[80] Fix | Delete
# * :ESCAPED (URI::PATTERN::ESCAPED in default)
[81] Fix | Delete
# * :UNRESERVED (URI::PATTERN::UNRESERVED in default)
[82] Fix | Delete
# * :DOMLABEL (URI::PATTERN::DOMLABEL in default)
[83] Fix | Delete
# * :TOPLABEL (URI::PATTERN::TOPLABEL in default)
[84] Fix | Delete
# * :HOSTNAME (URI::PATTERN::HOSTNAME in default)
[85] Fix | Delete
#
[86] Fix | Delete
# == Examples
[87] Fix | Delete
#
[88] Fix | Delete
# p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
[89] Fix | Delete
# u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
[90] Fix | Delete
# URI.parse(u.to_s) #=> raises URI::InvalidURIError
[91] Fix | Delete
#
[92] Fix | Delete
# s = "http://example.com/ABCD"
[93] Fix | Delete
# u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
[94] Fix | Delete
# u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
[95] Fix | Delete
# u1 == u2 #=> true
[96] Fix | Delete
# u1.eql?(u2) #=> false
[97] Fix | Delete
#
[98] Fix | Delete
def initialize(opts = {})
[99] Fix | Delete
@pattern = initialize_pattern(opts)
[100] Fix | Delete
@pattern.each_value(&:freeze)
[101] Fix | Delete
@pattern.freeze
[102] Fix | Delete
[103] Fix | Delete
@regexp = initialize_regexp(@pattern)
[104] Fix | Delete
@regexp.each_value(&:freeze)
[105] Fix | Delete
@regexp.freeze
[106] Fix | Delete
end
[107] Fix | Delete
[108] Fix | Delete
# The Hash of patterns.
[109] Fix | Delete
#
[110] Fix | Delete
# See also URI::Parser.initialize_pattern.
[111] Fix | Delete
attr_reader :pattern
[112] Fix | Delete
[113] Fix | Delete
# The Hash of Regexp.
[114] Fix | Delete
#
[115] Fix | Delete
# See also URI::Parser.initialize_regexp.
[116] Fix | Delete
attr_reader :regexp
[117] Fix | Delete
[118] Fix | Delete
# Returns a split URI against regexp[:ABS_URI].
[119] Fix | Delete
def split(uri)
[120] Fix | Delete
case uri
[121] Fix | Delete
when ''
[122] Fix | Delete
# null uri
[123] Fix | Delete
[124] Fix | Delete
when @regexp[:ABS_URI]
[125] Fix | Delete
scheme, opaque, userinfo, host, port,
[126] Fix | Delete
registry, path, query, fragment = $~[1..-1]
[127] Fix | Delete
[128] Fix | Delete
# URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
[129] Fix | Delete
[130] Fix | Delete
# absoluteURI = scheme ":" ( hier_part | opaque_part )
[131] Fix | Delete
# hier_part = ( net_path | abs_path ) [ "?" query ]
[132] Fix | Delete
# opaque_part = uric_no_slash *uric
[133] Fix | Delete
[134] Fix | Delete
# abs_path = "/" path_segments
[135] Fix | Delete
# net_path = "//" authority [ abs_path ]
[136] Fix | Delete
[137] Fix | Delete
# authority = server | reg_name
[138] Fix | Delete
# server = [ [ userinfo "@" ] hostport ]
[139] Fix | Delete
[140] Fix | Delete
if !scheme
[141] Fix | Delete
raise InvalidURIError,
[142] Fix | Delete
"bad URI(absolute but no scheme): #{uri}"
[143] Fix | Delete
end
[144] Fix | Delete
if !opaque && (!path && (!host && !registry))
[145] Fix | Delete
raise InvalidURIError,
[146] Fix | Delete
"bad URI(absolute but no path): #{uri}"
[147] Fix | Delete
end
[148] Fix | Delete
[149] Fix | Delete
when @regexp[:REL_URI]
[150] Fix | Delete
scheme = nil
[151] Fix | Delete
opaque = nil
[152] Fix | Delete
[153] Fix | Delete
userinfo, host, port, registry,
[154] Fix | Delete
rel_segment, abs_path, query, fragment = $~[1..-1]
[155] Fix | Delete
if rel_segment && abs_path
[156] Fix | Delete
path = rel_segment + abs_path
[157] Fix | Delete
elsif rel_segment
[158] Fix | Delete
path = rel_segment
[159] Fix | Delete
elsif abs_path
[160] Fix | Delete
path = abs_path
[161] Fix | Delete
end
[162] Fix | Delete
[163] Fix | Delete
# URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
[164] Fix | Delete
[165] Fix | Delete
# relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
[166] Fix | Delete
[167] Fix | Delete
# net_path = "//" authority [ abs_path ]
[168] Fix | Delete
# abs_path = "/" path_segments
[169] Fix | Delete
# rel_path = rel_segment [ abs_path ]
[170] Fix | Delete
[171] Fix | Delete
# authority = server | reg_name
[172] Fix | Delete
# server = [ [ userinfo "@" ] hostport ]
[173] Fix | Delete
[174] Fix | Delete
else
[175] Fix | Delete
raise InvalidURIError, "bad URI(is not URI?): #{uri}"
[176] Fix | Delete
end
[177] Fix | Delete
[178] Fix | Delete
path = '' if !path && !opaque # (see RFC2396 Section 5.2)
[179] Fix | Delete
ret = [
[180] Fix | Delete
scheme,
[181] Fix | Delete
userinfo, host, port, # X
[182] Fix | Delete
registry, # X
[183] Fix | Delete
path, # Y
[184] Fix | Delete
opaque, # Y
[185] Fix | Delete
query,
[186] Fix | Delete
fragment
[187] Fix | Delete
]
[188] Fix | Delete
return ret
[189] Fix | Delete
end
[190] Fix | Delete
[191] Fix | Delete
#
[192] Fix | Delete
# == Args
[193] Fix | Delete
#
[194] Fix | Delete
# +uri+::
[195] Fix | Delete
# String
[196] Fix | Delete
#
[197] Fix | Delete
# == Description
[198] Fix | Delete
#
[199] Fix | Delete
# Parses +uri+ and constructs either matching URI scheme object
[200] Fix | Delete
# (File, FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic.
[201] Fix | Delete
#
[202] Fix | Delete
# == Usage
[203] Fix | Delete
#
[204] Fix | Delete
# p = URI::Parser.new
[205] Fix | Delete
# p.parse("ldap://ldap.example.com/dc=example?user=john")
[206] Fix | Delete
# #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
[207] Fix | Delete
#
[208] Fix | Delete
def parse(uri)
[209] Fix | Delete
scheme, userinfo, host, port,
[210] Fix | Delete
registry, path, opaque, query, fragment = self.split(uri)
[211] Fix | Delete
[212] Fix | Delete
if scheme && URI.scheme_list.include?(scheme.upcase)
[213] Fix | Delete
URI.scheme_list[scheme.upcase].new(scheme, userinfo, host, port,
[214] Fix | Delete
registry, path, opaque, query,
[215] Fix | Delete
fragment, self)
[216] Fix | Delete
else
[217] Fix | Delete
Generic.new(scheme, userinfo, host, port,
[218] Fix | Delete
registry, path, opaque, query,
[219] Fix | Delete
fragment, self)
[220] Fix | Delete
end
[221] Fix | Delete
end
[222] Fix | Delete
[223] Fix | Delete
[224] Fix | Delete
#
[225] Fix | Delete
# == Args
[226] Fix | Delete
#
[227] Fix | Delete
# +uris+::
[228] Fix | Delete
# an Array of Strings
[229] Fix | Delete
#
[230] Fix | Delete
# == Description
[231] Fix | Delete
#
[232] Fix | Delete
# Attempts to parse and merge a set of URIs.
[233] Fix | Delete
#
[234] Fix | Delete
def join(*uris)
[235] Fix | Delete
uris[0] = convert_to_uri(uris[0])
[236] Fix | Delete
uris.inject :merge
[237] Fix | Delete
end
[238] Fix | Delete
[239] Fix | Delete
#
[240] Fix | Delete
# :call-seq:
[241] Fix | Delete
# extract( str )
[242] Fix | Delete
# extract( str, schemes )
[243] Fix | Delete
# extract( str, schemes ) {|item| block }
[244] Fix | Delete
#
[245] Fix | Delete
# == Args
[246] Fix | Delete
#
[247] Fix | Delete
# +str+::
[248] Fix | Delete
# String to search
[249] Fix | Delete
# +schemes+::
[250] Fix | Delete
# Patterns to apply to +str+
[251] Fix | Delete
#
[252] Fix | Delete
# == Description
[253] Fix | Delete
#
[254] Fix | Delete
# Attempts to parse and merge a set of URIs.
[255] Fix | Delete
# If no +block+ given, then returns the result,
[256] Fix | Delete
# else it calls +block+ for each element in result.
[257] Fix | Delete
#
[258] Fix | Delete
# See also URI::Parser.make_regexp.
[259] Fix | Delete
#
[260] Fix | Delete
def extract(str, schemes = nil)
[261] Fix | Delete
if block_given?
[262] Fix | Delete
str.scan(make_regexp(schemes)) { yield $& }
[263] Fix | Delete
nil
[264] Fix | Delete
else
[265] Fix | Delete
result = []
[266] Fix | Delete
str.scan(make_regexp(schemes)) { result.push $& }
[267] Fix | Delete
result
[268] Fix | Delete
end
[269] Fix | Delete
end
[270] Fix | Delete
[271] Fix | Delete
# Returns Regexp that is default self.regexp[:ABS_URI_REF],
[272] Fix | Delete
# unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI].
[273] Fix | Delete
def make_regexp(schemes = nil)
[274] Fix | Delete
unless schemes
[275] Fix | Delete
@regexp[:ABS_URI_REF]
[276] Fix | Delete
else
[277] Fix | Delete
/(?=#{Regexp.union(*schemes)}:)#{@pattern[:X_ABS_URI]}/x
[278] Fix | Delete
end
[279] Fix | Delete
end
[280] Fix | Delete
[281] Fix | Delete
#
[282] Fix | Delete
# :call-seq:
[283] Fix | Delete
# escape( str )
[284] Fix | Delete
# escape( str, unsafe )
[285] Fix | Delete
#
[286] Fix | Delete
# == Args
[287] Fix | Delete
#
[288] Fix | Delete
# +str+::
[289] Fix | Delete
# String to make safe
[290] Fix | Delete
# +unsafe+::
[291] Fix | Delete
# Regexp to apply. Defaults to self.regexp[:UNSAFE]
[292] Fix | Delete
#
[293] Fix | Delete
# == Description
[294] Fix | Delete
#
[295] Fix | Delete
# Constructs a safe String from +str+, removing unsafe characters,
[296] Fix | Delete
# replacing them with codes.
[297] Fix | Delete
#
[298] Fix | Delete
def escape(str, unsafe = @regexp[:UNSAFE])
[299] Fix | Delete
unless unsafe.kind_of?(Regexp)
[300] Fix | Delete
# perhaps unsafe is String object
[301] Fix | Delete
unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
[302] Fix | Delete
end
[303] Fix | Delete
str.gsub(unsafe) do
[304] Fix | Delete
us = $&
[305] Fix | Delete
tmp = ''
[306] Fix | Delete
us.each_byte do |uc|
[307] Fix | Delete
tmp << sprintf('%%%02X', uc)
[308] Fix | Delete
end
[309] Fix | Delete
tmp
[310] Fix | Delete
end.force_encoding(Encoding::US_ASCII)
[311] Fix | Delete
end
[312] Fix | Delete
[313] Fix | Delete
#
[314] Fix | Delete
# :call-seq:
[315] Fix | Delete
# unescape( str )
[316] Fix | Delete
# unescape( str, escaped )
[317] Fix | Delete
#
[318] Fix | Delete
# == Args
[319] Fix | Delete
#
[320] Fix | Delete
# +str+::
[321] Fix | Delete
# String to remove escapes from
[322] Fix | Delete
# +escaped+::
[323] Fix | Delete
# Regexp to apply. Defaults to self.regexp[:ESCAPED]
[324] Fix | Delete
#
[325] Fix | Delete
# == Description
[326] Fix | Delete
#
[327] Fix | Delete
# Removes escapes from +str+.
[328] Fix | Delete
#
[329] Fix | Delete
def unescape(str, escaped = @regexp[:ESCAPED])
[330] Fix | Delete
enc = str.encoding
[331] Fix | Delete
enc = Encoding::UTF_8 if enc == Encoding::US_ASCII
[332] Fix | Delete
str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }
[333] Fix | Delete
end
[334] Fix | Delete
[335] Fix | Delete
@@to_s = Kernel.instance_method(:to_s)
[336] Fix | Delete
def inspect
[337] Fix | Delete
@@to_s.bind_call(self)
[338] Fix | Delete
end
[339] Fix | Delete
[340] Fix | Delete
private
[341] Fix | Delete
[342] Fix | Delete
# Constructs the default Hash of patterns.
[343] Fix | Delete
def initialize_pattern(opts = {})
[344] Fix | Delete
ret = {}
[345] Fix | Delete
ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
[346] Fix | Delete
ret[:UNRESERVED] = unreserved = opts.delete(:UNRESERVED) || PATTERN::UNRESERVED
[347] Fix | Delete
ret[:RESERVED] = reserved = opts.delete(:RESERVED) || PATTERN::RESERVED
[348] Fix | Delete
ret[:DOMLABEL] = opts.delete(:DOMLABEL) || PATTERN::DOMLABEL
[349] Fix | Delete
ret[:TOPLABEL] = opts.delete(:TOPLABEL) || PATTERN::TOPLABEL
[350] Fix | Delete
ret[:HOSTNAME] = hostname = opts.delete(:HOSTNAME)
[351] Fix | Delete
[352] Fix | Delete
# RFC 2396 (URI Generic Syntax)
[353] Fix | Delete
# RFC 2732 (IPv6 Literal Addresses in URL's)
[354] Fix | Delete
# RFC 2373 (IPv6 Addressing Architecture)
[355] Fix | Delete
[356] Fix | Delete
# uric = reserved | unreserved | escaped
[357] Fix | Delete
ret[:URIC] = uric = "(?:[#{unreserved}#{reserved}]|#{escaped})"
[358] Fix | Delete
# uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
[359] Fix | Delete
# "&" | "=" | "+" | "$" | ","
[360] Fix | Delete
ret[:URIC_NO_SLASH] = uric_no_slash = "(?:[#{unreserved};?:@&=+$,]|#{escaped})"
[361] Fix | Delete
# query = *uric
[362] Fix | Delete
ret[:QUERY] = query = "#{uric}*"
[363] Fix | Delete
# fragment = *uric
[364] Fix | Delete
ret[:FRAGMENT] = fragment = "#{uric}*"
[365] Fix | Delete
[366] Fix | Delete
# hostname = *( domainlabel "." ) toplabel [ "." ]
[367] Fix | Delete
# reg-name = *( unreserved / pct-encoded / sub-delims ) # RFC3986
[368] Fix | Delete
unless hostname
[369] Fix | Delete
ret[:HOSTNAME] = hostname = "(?:[a-zA-Z0-9\\-.]|%\\h\\h)+"
[370] Fix | Delete
end
[371] Fix | Delete
[372] Fix | Delete
# RFC 2373, APPENDIX B:
[373] Fix | Delete
# IPv6address = hexpart [ ":" IPv4address ]
[374] Fix | Delete
# IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
[375] Fix | Delete
# hexpart = hexseq | hexseq "::" [ hexseq ] | "::" [ hexseq ]
[376] Fix | Delete
# hexseq = hex4 *( ":" hex4)
[377] Fix | Delete
# hex4 = 1*4HEXDIG
[378] Fix | Delete
#
[379] Fix | Delete
# XXX: This definition has a flaw. "::" + IPv4address must be
[380] Fix | Delete
# allowed too. Here is a replacement.
[381] Fix | Delete
#
[382] Fix | Delete
# IPv4address = 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT "." 1*3DIGIT
[383] Fix | Delete
ret[:IPV4ADDR] = ipv4addr = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}"
[384] Fix | Delete
# hex4 = 1*4HEXDIG
[385] Fix | Delete
hex4 = "[#{PATTERN::HEX}]{1,4}"
[386] Fix | Delete
# lastpart = hex4 | IPv4address
[387] Fix | Delete
lastpart = "(?:#{hex4}|#{ipv4addr})"
[388] Fix | Delete
# hexseq1 = *( hex4 ":" ) hex4
[389] Fix | Delete
hexseq1 = "(?:#{hex4}:)*#{hex4}"
[390] Fix | Delete
# hexseq2 = *( hex4 ":" ) lastpart
[391] Fix | Delete
hexseq2 = "(?:#{hex4}:)*#{lastpart}"
[392] Fix | Delete
# IPv6address = hexseq2 | [ hexseq1 ] "::" [ hexseq2 ]
[393] Fix | Delete
ret[:IPV6ADDR] = ipv6addr = "(?:#{hexseq2}|(?:#{hexseq1})?::(?:#{hexseq2})?)"
[394] Fix | Delete
[395] Fix | Delete
# IPv6prefix = ( hexseq1 | [ hexseq1 ] "::" [ hexseq1 ] ) "/" 1*2DIGIT
[396] Fix | Delete
# unused
[397] Fix | Delete
[398] Fix | Delete
# ipv6reference = "[" IPv6address "]" (RFC 2732)
[399] Fix | Delete
ret[:IPV6REF] = ipv6ref = "\\[#{ipv6addr}\\]"
[400] Fix | Delete
[401] Fix | Delete
# host = hostname | IPv4address
[402] Fix | Delete
# host = hostname | IPv4address | IPv6reference (RFC 2732)
[403] Fix | Delete
ret[:HOST] = host = "(?:#{hostname}|#{ipv4addr}|#{ipv6ref})"
[404] Fix | Delete
# port = *digit
[405] Fix | Delete
ret[:PORT] = port = '\d*'
[406] Fix | Delete
# hostport = host [ ":" port ]
[407] Fix | Delete
ret[:HOSTPORT] = hostport = "#{host}(?::#{port})?"
[408] Fix | Delete
[409] Fix | Delete
# userinfo = *( unreserved | escaped |
[410] Fix | Delete
# ";" | ":" | "&" | "=" | "+" | "$" | "," )
[411] Fix | Delete
ret[:USERINFO] = userinfo = "(?:[#{unreserved};:&=+$,]|#{escaped})*"
[412] Fix | Delete
[413] Fix | Delete
# pchar = unreserved | escaped |
[414] Fix | Delete
# ":" | "@" | "&" | "=" | "+" | "$" | ","
[415] Fix | Delete
pchar = "(?:[#{unreserved}:@&=+$,]|#{escaped})"
[416] Fix | Delete
# param = *pchar
[417] Fix | Delete
param = "#{pchar}*"
[418] Fix | Delete
# segment = *pchar *( ";" param )
[419] Fix | Delete
segment = "#{pchar}*(?:;#{param})*"
[420] Fix | Delete
# path_segments = segment *( "/" segment )
[421] Fix | Delete
ret[:PATH_SEGMENTS] = path_segments = "#{segment}(?:/#{segment})*"
[422] Fix | Delete
[423] Fix | Delete
# server = [ [ userinfo "@" ] hostport ]
[424] Fix | Delete
server = "(?:#{userinfo}@)?#{hostport}"
[425] Fix | Delete
# reg_name = 1*( unreserved | escaped | "$" | "," |
[426] Fix | Delete
# ";" | ":" | "@" | "&" | "=" | "+" )
[427] Fix | Delete
ret[:REG_NAME] = reg_name = "(?:[#{unreserved}$,;:@&=+]|#{escaped})+"
[428] Fix | Delete
# authority = server | reg_name
[429] Fix | Delete
authority = "(?:#{server}|#{reg_name})"
[430] Fix | Delete
[431] Fix | Delete
# rel_segment = 1*( unreserved | escaped |
[432] Fix | Delete
# ";" | "@" | "&" | "=" | "+" | "$" | "," )
[433] Fix | Delete
ret[:REL_SEGMENT] = rel_segment = "(?:[#{unreserved};@&=+$,]|#{escaped})+"
[434] Fix | Delete
[435] Fix | Delete
# scheme = alpha *( alpha | digit | "+" | "-" | "." )
[436] Fix | Delete
ret[:SCHEME] = scheme = "[#{PATTERN::ALPHA}][\\-+.#{PATTERN::ALPHA}\\d]*"
[437] Fix | Delete
[438] Fix | Delete
# abs_path = "/" path_segments
[439] Fix | Delete
ret[:ABS_PATH] = abs_path = "/#{path_segments}"
[440] Fix | Delete
# rel_path = rel_segment [ abs_path ]
[441] Fix | Delete
ret[:REL_PATH] = rel_path = "#{rel_segment}(?:#{abs_path})?"
[442] Fix | Delete
# net_path = "//" authority [ abs_path ]
[443] Fix | Delete
ret[:NET_PATH] = net_path = "//#{authority}(?:#{abs_path})?"
[444] Fix | Delete
[445] Fix | Delete
# hier_part = ( net_path | abs_path ) [ "?" query ]
[446] Fix | Delete
ret[:HIER_PART] = hier_part = "(?:#{net_path}|#{abs_path})(?:\\?(?:#{query}))?"
[447] Fix | Delete
# opaque_part = uric_no_slash *uric
[448] Fix | Delete
ret[:OPAQUE_PART] = opaque_part = "#{uric_no_slash}#{uric}*"
[449] Fix | Delete
[450] Fix | Delete
# absoluteURI = scheme ":" ( hier_part | opaque_part )
[451] Fix | Delete
ret[:ABS_URI] = abs_uri = "#{scheme}:(?:#{hier_part}|#{opaque_part})"
[452] Fix | Delete
# relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
[453] Fix | Delete
ret[:REL_URI] = rel_uri = "(?:#{net_path}|#{abs_path}|#{rel_path})(?:\\?#{query})?"
[454] Fix | Delete
[455] Fix | Delete
# URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
[456] Fix | Delete
ret[:URI_REF] = "(?:#{abs_uri}|#{rel_uri})?(?:##{fragment})?"
[457] Fix | Delete
[458] Fix | Delete
ret[:X_ABS_URI] = "
[459] Fix | Delete
(#{scheme}): (?# 1: scheme)
[460] Fix | Delete
(?:
[461] Fix | Delete
(#{opaque_part}) (?# 2: opaque)
[462] Fix | Delete
|
[463] Fix | Delete
(?:(?:
[464] Fix | Delete
//(?:
[465] Fix | Delete
(?:(?:(#{userinfo})@)? (?# 3: userinfo)
[466] Fix | Delete
(?:(#{host})(?::(\\d*))?))? (?# 4: host, 5: port)
[467] Fix | Delete
|
[468] Fix | Delete
(#{reg_name}) (?# 6: registry)
[469] Fix | Delete
)
[470] Fix | Delete
|
[471] Fix | Delete
(?!//)) (?# XXX: '//' is the mark for hostport)
[472] Fix | Delete
(#{abs_path})? (?# 7: path)
[473] Fix | Delete
)(?:\\?(#{query}))? (?# 8: query)
[474] Fix | Delete
)
[475] Fix | Delete
(?:\\#(#{fragment}))? (?# 9: fragment)
[476] Fix | Delete
"
[477] Fix | Delete
[478] Fix | Delete
ret[:X_REL_URI] = "
[479] Fix | Delete
(?:
[480] Fix | Delete
(?:
[481] Fix | Delete
//
[482] Fix | Delete
(?:
[483] Fix | Delete
(?:(#{userinfo})@)? (?# 1: userinfo)
[484] Fix | Delete
(#{host})?(?::(\\d*))? (?# 2: host, 3: port)
[485] Fix | Delete
|
[486] Fix | Delete
(#{reg_name}) (?# 4: registry)
[487] Fix | Delete
)
[488] Fix | Delete
)
[489] Fix | Delete
|
[490] Fix | Delete
(#{rel_segment}) (?# 5: rel_segment)
[491] Fix | Delete
)?
[492] Fix | Delete
(#{abs_path})? (?# 6: abs_path)
[493] Fix | Delete
(?:\\?(#{query}))? (?# 7: query)
[494] Fix | Delete
(?:\\#(#{fragment}))? (?# 8: fragment)
[495] Fix | Delete
"
[496] Fix | Delete
[497] Fix | Delete
ret
[498] Fix | Delete
end
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function