Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby27/share/ruby/uri
File: common.rb
# frozen_string_literal: true
[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
require_relative "rfc2396_parser"
[12] Fix | Delete
require_relative "rfc3986_parser"
[13] Fix | Delete
[14] Fix | Delete
module URI
[15] Fix | Delete
REGEXP = RFC2396_REGEXP
[16] Fix | Delete
Parser = RFC2396_Parser
[17] Fix | Delete
RFC3986_PARSER = RFC3986_Parser.new
[18] Fix | Delete
[19] Fix | Delete
# URI::Parser.new
[20] Fix | Delete
DEFAULT_PARSER = Parser.new
[21] Fix | Delete
DEFAULT_PARSER.pattern.each_pair do |sym, str|
[22] Fix | Delete
unless REGEXP::PATTERN.const_defined?(sym)
[23] Fix | Delete
REGEXP::PATTERN.const_set(sym, str)
[24] Fix | Delete
end
[25] Fix | Delete
end
[26] Fix | Delete
DEFAULT_PARSER.regexp.each_pair do |sym, str|
[27] Fix | Delete
const_set(sym, str)
[28] Fix | Delete
end
[29] Fix | Delete
[30] Fix | Delete
module Util # :nodoc:
[31] Fix | Delete
def make_components_hash(klass, array_hash)
[32] Fix | Delete
tmp = {}
[33] Fix | Delete
if array_hash.kind_of?(Array) &&
[34] Fix | Delete
array_hash.size == klass.component.size - 1
[35] Fix | Delete
klass.component[1..-1].each_index do |i|
[36] Fix | Delete
begin
[37] Fix | Delete
tmp[klass.component[i + 1]] = array_hash[i].clone
[38] Fix | Delete
rescue TypeError
[39] Fix | Delete
tmp[klass.component[i + 1]] = array_hash[i]
[40] Fix | Delete
end
[41] Fix | Delete
end
[42] Fix | Delete
[43] Fix | Delete
elsif array_hash.kind_of?(Hash)
[44] Fix | Delete
array_hash.each do |key, value|
[45] Fix | Delete
begin
[46] Fix | Delete
tmp[key] = value.clone
[47] Fix | Delete
rescue TypeError
[48] Fix | Delete
tmp[key] = value
[49] Fix | Delete
end
[50] Fix | Delete
end
[51] Fix | Delete
else
[52] Fix | Delete
raise ArgumentError,
[53] Fix | Delete
"expected Array of or Hash of components of #{klass} (#{klass.component[1..-1].join(', ')})"
[54] Fix | Delete
end
[55] Fix | Delete
tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
[56] Fix | Delete
[57] Fix | Delete
return tmp
[58] Fix | Delete
end
[59] Fix | Delete
module_function :make_components_hash
[60] Fix | Delete
end
[61] Fix | Delete
[62] Fix | Delete
# Module for escaping unsafe characters with codes.
[63] Fix | Delete
module Escape
[64] Fix | Delete
#
[65] Fix | Delete
# == Synopsis
[66] Fix | Delete
#
[67] Fix | Delete
# URI.escape(str [, unsafe])
[68] Fix | Delete
#
[69] Fix | Delete
# == Args
[70] Fix | Delete
#
[71] Fix | Delete
# +str+::
[72] Fix | Delete
# String to replaces in.
[73] Fix | Delete
# +unsafe+::
[74] Fix | Delete
# Regexp that matches all symbols that must be replaced with codes.
[75] Fix | Delete
# By default uses <tt>UNSAFE</tt>.
[76] Fix | Delete
# When this argument is a String, it represents a character set.
[77] Fix | Delete
#
[78] Fix | Delete
# == Description
[79] Fix | Delete
#
[80] Fix | Delete
# Escapes the string, replacing all unsafe characters with codes.
[81] Fix | Delete
#
[82] Fix | Delete
# This method is obsolete and should not be used. Instead, use
[83] Fix | Delete
# CGI.escape, URI.encode_www_form or URI.encode_www_form_component
[84] Fix | Delete
# depending on your specific use case.
[85] Fix | Delete
#
[86] Fix | Delete
# == Usage
[87] Fix | Delete
#
[88] Fix | Delete
# require 'uri'
[89] Fix | Delete
#
[90] Fix | Delete
# enc_uri = URI.escape("http://example.com/?a=\11\15")
[91] Fix | Delete
# # => "http://example.com/?a=%09%0D"
[92] Fix | Delete
#
[93] Fix | Delete
# URI.unescape(enc_uri)
[94] Fix | Delete
# # => "http://example.com/?a=\t\r"
[95] Fix | Delete
#
[96] Fix | Delete
# URI.escape("@?@!", "!?")
[97] Fix | Delete
# # => "@%3F@%21"
[98] Fix | Delete
#
[99] Fix | Delete
def escape(*arg)
[100] Fix | Delete
warn "URI.escape is obsolete", uplevel: 1
[101] Fix | Delete
DEFAULT_PARSER.escape(*arg)
[102] Fix | Delete
end
[103] Fix | Delete
alias encode escape
[104] Fix | Delete
#
[105] Fix | Delete
# == Synopsis
[106] Fix | Delete
#
[107] Fix | Delete
# URI.unescape(str)
[108] Fix | Delete
#
[109] Fix | Delete
# == Args
[110] Fix | Delete
#
[111] Fix | Delete
# +str+::
[112] Fix | Delete
# String to unescape.
[113] Fix | Delete
#
[114] Fix | Delete
# == Description
[115] Fix | Delete
#
[116] Fix | Delete
# This method is obsolete and should not be used. Instead, use
[117] Fix | Delete
# CGI.unescape, URI.decode_www_form or URI.decode_www_form_component
[118] Fix | Delete
# depending on your specific use case.
[119] Fix | Delete
#
[120] Fix | Delete
# == Usage
[121] Fix | Delete
#
[122] Fix | Delete
# require 'uri'
[123] Fix | Delete
#
[124] Fix | Delete
# enc_uri = URI.escape("http://example.com/?a=\11\15")
[125] Fix | Delete
# # => "http://example.com/?a=%09%0D"
[126] Fix | Delete
#
[127] Fix | Delete
# URI.unescape(enc_uri)
[128] Fix | Delete
# # => "http://example.com/?a=\t\r"
[129] Fix | Delete
#
[130] Fix | Delete
def unescape(*arg)
[131] Fix | Delete
warn "URI.unescape is obsolete", uplevel: 1
[132] Fix | Delete
DEFAULT_PARSER.unescape(*arg)
[133] Fix | Delete
end
[134] Fix | Delete
alias decode unescape
[135] Fix | Delete
end # module Escape
[136] Fix | Delete
[137] Fix | Delete
extend Escape
[138] Fix | Delete
include REGEXP
[139] Fix | Delete
[140] Fix | Delete
@@schemes = {}
[141] Fix | Delete
# Returns a Hash of the defined schemes.
[142] Fix | Delete
def self.scheme_list
[143] Fix | Delete
@@schemes
[144] Fix | Delete
end
[145] Fix | Delete
[146] Fix | Delete
#
[147] Fix | Delete
# Base class for all URI exceptions.
[148] Fix | Delete
#
[149] Fix | Delete
class Error < StandardError; end
[150] Fix | Delete
#
[151] Fix | Delete
# Not a URI.
[152] Fix | Delete
#
[153] Fix | Delete
class InvalidURIError < Error; end
[154] Fix | Delete
#
[155] Fix | Delete
# Not a URI component.
[156] Fix | Delete
#
[157] Fix | Delete
class InvalidComponentError < Error; end
[158] Fix | Delete
#
[159] Fix | Delete
# URI is valid, bad usage is not.
[160] Fix | Delete
#
[161] Fix | Delete
class BadURIError < Error; end
[162] Fix | Delete
[163] Fix | Delete
#
[164] Fix | Delete
# == Synopsis
[165] Fix | Delete
#
[166] Fix | Delete
# URI::split(uri)
[167] Fix | Delete
#
[168] Fix | Delete
# == Args
[169] Fix | Delete
#
[170] Fix | Delete
# +uri+::
[171] Fix | Delete
# String with URI.
[172] Fix | Delete
#
[173] Fix | Delete
# == Description
[174] Fix | Delete
#
[175] Fix | Delete
# Splits the string on following parts and returns array with result:
[176] Fix | Delete
#
[177] Fix | Delete
# * Scheme
[178] Fix | Delete
# * Userinfo
[179] Fix | Delete
# * Host
[180] Fix | Delete
# * Port
[181] Fix | Delete
# * Registry
[182] Fix | Delete
# * Path
[183] Fix | Delete
# * Opaque
[184] Fix | Delete
# * Query
[185] Fix | Delete
# * Fragment
[186] Fix | Delete
#
[187] Fix | Delete
# == Usage
[188] Fix | Delete
#
[189] Fix | Delete
# require 'uri'
[190] Fix | Delete
#
[191] Fix | Delete
# URI.split("http://www.ruby-lang.org/")
[192] Fix | Delete
# # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
[193] Fix | Delete
#
[194] Fix | Delete
def self.split(uri)
[195] Fix | Delete
RFC3986_PARSER.split(uri)
[196] Fix | Delete
end
[197] Fix | Delete
[198] Fix | Delete
#
[199] Fix | Delete
# == Synopsis
[200] Fix | Delete
#
[201] Fix | Delete
# URI::parse(uri_str)
[202] Fix | Delete
#
[203] Fix | Delete
# == Args
[204] Fix | Delete
#
[205] Fix | Delete
# +uri_str+::
[206] Fix | Delete
# String with URI.
[207] Fix | Delete
#
[208] Fix | Delete
# == Description
[209] Fix | Delete
#
[210] Fix | Delete
# Creates one of the URI's subclasses instance from the string.
[211] Fix | Delete
#
[212] Fix | Delete
# == Raises
[213] Fix | Delete
#
[214] Fix | Delete
# URI::InvalidURIError::
[215] Fix | Delete
# Raised if URI given is not a correct one.
[216] Fix | Delete
#
[217] Fix | Delete
# == Usage
[218] Fix | Delete
#
[219] Fix | Delete
# require 'uri'
[220] Fix | Delete
#
[221] Fix | Delete
# uri = URI.parse("http://www.ruby-lang.org/")
[222] Fix | Delete
# # => #<URI::HTTP http://www.ruby-lang.org/>
[223] Fix | Delete
# uri.scheme
[224] Fix | Delete
# # => "http"
[225] Fix | Delete
# uri.host
[226] Fix | Delete
# # => "www.ruby-lang.org"
[227] Fix | Delete
#
[228] Fix | Delete
# It's recommended to first ::escape the provided +uri_str+ if there are any
[229] Fix | Delete
# invalid URI characters.
[230] Fix | Delete
#
[231] Fix | Delete
def self.parse(uri)
[232] Fix | Delete
RFC3986_PARSER.parse(uri)
[233] Fix | Delete
end
[234] Fix | Delete
[235] Fix | Delete
#
[236] Fix | Delete
# == Synopsis
[237] Fix | Delete
#
[238] Fix | Delete
# URI::join(str[, str, ...])
[239] Fix | Delete
#
[240] Fix | Delete
# == Args
[241] Fix | Delete
#
[242] Fix | Delete
# +str+::
[243] Fix | Delete
# String(s) to work with, will be converted to RFC3986 URIs before merging.
[244] Fix | Delete
#
[245] Fix | Delete
# == Description
[246] Fix | Delete
#
[247] Fix | Delete
# Joins URIs.
[248] Fix | Delete
#
[249] Fix | Delete
# == Usage
[250] Fix | Delete
#
[251] Fix | Delete
# require 'uri'
[252] Fix | Delete
#
[253] Fix | Delete
# URI.join("http://example.com/","main.rbx")
[254] Fix | Delete
# # => #<URI::HTTP http://example.com/main.rbx>
[255] Fix | Delete
#
[256] Fix | Delete
# URI.join('http://example.com', 'foo')
[257] Fix | Delete
# # => #<URI::HTTP http://example.com/foo>
[258] Fix | Delete
#
[259] Fix | Delete
# URI.join('http://example.com', '/foo', '/bar')
[260] Fix | Delete
# # => #<URI::HTTP http://example.com/bar>
[261] Fix | Delete
#
[262] Fix | Delete
# URI.join('http://example.com', '/foo', 'bar')
[263] Fix | Delete
# # => #<URI::HTTP http://example.com/bar>
[264] Fix | Delete
#
[265] Fix | Delete
# URI.join('http://example.com', '/foo/', 'bar')
[266] Fix | Delete
# # => #<URI::HTTP http://example.com/foo/bar>
[267] Fix | Delete
#
[268] Fix | Delete
def self.join(*str)
[269] Fix | Delete
RFC3986_PARSER.join(*str)
[270] Fix | Delete
end
[271] Fix | Delete
[272] Fix | Delete
#
[273] Fix | Delete
# == Synopsis
[274] Fix | Delete
#
[275] Fix | Delete
# URI::extract(str[, schemes][,&blk])
[276] Fix | Delete
#
[277] Fix | Delete
# == Args
[278] Fix | Delete
#
[279] Fix | Delete
# +str+::
[280] Fix | Delete
# String to extract URIs from.
[281] Fix | Delete
# +schemes+::
[282] Fix | Delete
# Limit URI matching to specific schemes.
[283] Fix | Delete
#
[284] Fix | Delete
# == Description
[285] Fix | Delete
#
[286] Fix | Delete
# Extracts URIs from a string. If block given, iterates through all matched URIs.
[287] Fix | Delete
# Returns nil if block given or array with matches.
[288] Fix | Delete
#
[289] Fix | Delete
# == Usage
[290] Fix | Delete
#
[291] Fix | Delete
# require "uri"
[292] Fix | Delete
#
[293] Fix | Delete
# URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
[294] Fix | Delete
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
[295] Fix | Delete
#
[296] Fix | Delete
def self.extract(str, schemes = nil, &block)
[297] Fix | Delete
warn "URI.extract is obsolete", uplevel: 1 if $VERBOSE
[298] Fix | Delete
DEFAULT_PARSER.extract(str, schemes, &block)
[299] Fix | Delete
end
[300] Fix | Delete
[301] Fix | Delete
#
[302] Fix | Delete
# == Synopsis
[303] Fix | Delete
#
[304] Fix | Delete
# URI::regexp([match_schemes])
[305] Fix | Delete
#
[306] Fix | Delete
# == Args
[307] Fix | Delete
#
[308] Fix | Delete
# +match_schemes+::
[309] Fix | Delete
# Array of schemes. If given, resulting regexp matches to URIs
[310] Fix | Delete
# whose scheme is one of the match_schemes.
[311] Fix | Delete
#
[312] Fix | Delete
# == Description
[313] Fix | Delete
#
[314] Fix | Delete
# Returns a Regexp object which matches to URI-like strings.
[315] Fix | Delete
# The Regexp object returned by this method includes arbitrary
[316] Fix | Delete
# number of capture group (parentheses). Never rely on it's number.
[317] Fix | Delete
#
[318] Fix | Delete
# == Usage
[319] Fix | Delete
#
[320] Fix | Delete
# require 'uri'
[321] Fix | Delete
#
[322] Fix | Delete
# # extract first URI from html_string
[323] Fix | Delete
# html_string.slice(URI.regexp)
[324] Fix | Delete
#
[325] Fix | Delete
# # remove ftp URIs
[326] Fix | Delete
# html_string.sub(URI.regexp(['ftp']), '')
[327] Fix | Delete
#
[328] Fix | Delete
# # You should not rely on the number of parentheses
[329] Fix | Delete
# html_string.scan(URI.regexp) do |*matches|
[330] Fix | Delete
# p $&
[331] Fix | Delete
# end
[332] Fix | Delete
#
[333] Fix | Delete
def self.regexp(schemes = nil)
[334] Fix | Delete
warn "URI.regexp is obsolete", uplevel: 1 if $VERBOSE
[335] Fix | Delete
DEFAULT_PARSER.make_regexp(schemes)
[336] Fix | Delete
end
[337] Fix | Delete
[338] Fix | Delete
TBLENCWWWCOMP_ = {} # :nodoc:
[339] Fix | Delete
256.times do |i|
[340] Fix | Delete
TBLENCWWWCOMP_[-i.chr] = -('%%%02X' % i)
[341] Fix | Delete
end
[342] Fix | Delete
TBLENCWWWCOMP_[' '] = '+'
[343] Fix | Delete
TBLENCWWWCOMP_.freeze
[344] Fix | Delete
TBLDECWWWCOMP_ = {} # :nodoc:
[345] Fix | Delete
256.times do |i|
[346] Fix | Delete
h, l = i>>4, i&15
[347] Fix | Delete
TBLDECWWWCOMP_[-('%%%X%X' % [h, l])] = -i.chr
[348] Fix | Delete
TBLDECWWWCOMP_[-('%%%x%X' % [h, l])] = -i.chr
[349] Fix | Delete
TBLDECWWWCOMP_[-('%%%X%x' % [h, l])] = -i.chr
[350] Fix | Delete
TBLDECWWWCOMP_[-('%%%x%x' % [h, l])] = -i.chr
[351] Fix | Delete
end
[352] Fix | Delete
TBLDECWWWCOMP_['+'] = ' '
[353] Fix | Delete
TBLDECWWWCOMP_.freeze
[354] Fix | Delete
[355] Fix | Delete
# Encodes given +str+ to URL-encoded form data.
[356] Fix | Delete
#
[357] Fix | Delete
# This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
[358] Fix | Delete
# (ASCII space) to + and converts others to %XX.
[359] Fix | Delete
#
[360] Fix | Delete
# If +enc+ is given, convert +str+ to the encoding before percent encoding.
[361] Fix | Delete
#
[362] Fix | Delete
# This is an implementation of
[363] Fix | Delete
# http://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
[364] Fix | Delete
#
[365] Fix | Delete
# See URI.decode_www_form_component, URI.encode_www_form.
[366] Fix | Delete
def self.encode_www_form_component(str, enc=nil)
[367] Fix | Delete
str = str.to_s.dup
[368] Fix | Delete
if str.encoding != Encoding::ASCII_8BIT
[369] Fix | Delete
if enc && enc != Encoding::ASCII_8BIT
[370] Fix | Delete
str.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace)
[371] Fix | Delete
str.encode!(enc, fallback: ->(x){"&##{x.ord};"})
[372] Fix | Delete
end
[373] Fix | Delete
str.force_encoding(Encoding::ASCII_8BIT)
[374] Fix | Delete
end
[375] Fix | Delete
str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
[376] Fix | Delete
str.force_encoding(Encoding::US_ASCII)
[377] Fix | Delete
end
[378] Fix | Delete
[379] Fix | Delete
# Decodes given +str+ of URL-encoded form data.
[380] Fix | Delete
#
[381] Fix | Delete
# This decodes + to SP.
[382] Fix | Delete
#
[383] Fix | Delete
# See URI.encode_www_form_component, URI.decode_www_form.
[384] Fix | Delete
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
[385] Fix | Delete
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
[386] Fix | Delete
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
[387] Fix | Delete
end
[388] Fix | Delete
[389] Fix | Delete
# Generates URL-encoded form data from given +enum+.
[390] Fix | Delete
#
[391] Fix | Delete
# This generates application/x-www-form-urlencoded data defined in HTML5
[392] Fix | Delete
# from given an Enumerable object.
[393] Fix | Delete
#
[394] Fix | Delete
# This internally uses URI.encode_www_form_component(str).
[395] Fix | Delete
#
[396] Fix | Delete
# This method doesn't convert the encoding of given items, so convert them
[397] Fix | Delete
# before calling this method if you want to send data as other than original
[398] Fix | Delete
# encoding or mixed encoding data. (Strings which are encoded in an HTML5
[399] Fix | Delete
# ASCII incompatible encoding are converted to UTF-8.)
[400] Fix | Delete
#
[401] Fix | Delete
# This method doesn't handle files. When you send a file, use
[402] Fix | Delete
# multipart/form-data.
[403] Fix | Delete
#
[404] Fix | Delete
# This refers http://url.spec.whatwg.org/#concept-urlencoded-serializer
[405] Fix | Delete
#
[406] Fix | Delete
# URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
[407] Fix | Delete
# #=> "q=ruby&lang=en"
[408] Fix | Delete
# URI.encode_www_form("q" => "ruby", "lang" => "en")
[409] Fix | Delete
# #=> "q=ruby&lang=en"
[410] Fix | Delete
# URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
[411] Fix | Delete
# #=> "q=ruby&q=perl&lang=en"
[412] Fix | Delete
# URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
[413] Fix | Delete
# #=> "q=ruby&q=perl&lang=en"
[414] Fix | Delete
#
[415] Fix | Delete
# See URI.encode_www_form_component, URI.decode_www_form.
[416] Fix | Delete
def self.encode_www_form(enum, enc=nil)
[417] Fix | Delete
enum.map do |k,v|
[418] Fix | Delete
if v.nil?
[419] Fix | Delete
encode_www_form_component(k, enc)
[420] Fix | Delete
elsif v.respond_to?(:to_ary)
[421] Fix | Delete
v.to_ary.map do |w|
[422] Fix | Delete
str = encode_www_form_component(k, enc)
[423] Fix | Delete
unless w.nil?
[424] Fix | Delete
str << '='
[425] Fix | Delete
str << encode_www_form_component(w, enc)
[426] Fix | Delete
end
[427] Fix | Delete
end.join('&')
[428] Fix | Delete
else
[429] Fix | Delete
str = encode_www_form_component(k, enc)
[430] Fix | Delete
str << '='
[431] Fix | Delete
str << encode_www_form_component(v, enc)
[432] Fix | Delete
end
[433] Fix | Delete
end.join('&')
[434] Fix | Delete
end
[435] Fix | Delete
[436] Fix | Delete
# Decodes URL-encoded form data from given +str+.
[437] Fix | Delete
#
[438] Fix | Delete
# This decodes application/x-www-form-urlencoded data
[439] Fix | Delete
# and returns an array of key-value arrays.
[440] Fix | Delete
#
[441] Fix | Delete
# This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
[442] Fix | Delete
# so this supports only &-separator, and doesn't support ;-separator.
[443] Fix | Delete
#
[444] Fix | Delete
# ary = URI.decode_www_form("a=1&a=2&b=3")
[445] Fix | Delete
# ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
[446] Fix | Delete
# ary.assoc('a').last #=> '1'
[447] Fix | Delete
# ary.assoc('b').last #=> '3'
[448] Fix | Delete
# ary.rassoc('a').last #=> '2'
[449] Fix | Delete
# Hash[ary] #=> {"a"=>"2", "b"=>"3"}
[450] Fix | Delete
#
[451] Fix | Delete
# See URI.decode_www_form_component, URI.encode_www_form.
[452] Fix | Delete
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
[453] Fix | Delete
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
[454] Fix | Delete
ary = []
[455] Fix | Delete
return ary if str.empty?
[456] Fix | Delete
enc = Encoding.find(enc)
[457] Fix | Delete
str.b.each_line(separator) do |string|
[458] Fix | Delete
string.chomp!(separator)
[459] Fix | Delete
key, sep, val = string.partition('=')
[460] Fix | Delete
if isindex
[461] Fix | Delete
if sep.empty?
[462] Fix | Delete
val = key
[463] Fix | Delete
key = +''
[464] Fix | Delete
end
[465] Fix | Delete
isindex = false
[466] Fix | Delete
end
[467] Fix | Delete
[468] Fix | Delete
if use__charset_ and key == '_charset_' and e = get_encoding(val)
[469] Fix | Delete
enc = e
[470] Fix | Delete
use__charset_ = false
[471] Fix | Delete
end
[472] Fix | Delete
[473] Fix | Delete
key.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
[474] Fix | Delete
if val
[475] Fix | Delete
val.gsub!(/\+|%\h\h/, TBLDECWWWCOMP_)
[476] Fix | Delete
else
[477] Fix | Delete
val = +''
[478] Fix | Delete
end
[479] Fix | Delete
[480] Fix | Delete
ary << [key, val]
[481] Fix | Delete
end
[482] Fix | Delete
ary.each do |k, v|
[483] Fix | Delete
k.force_encoding(enc)
[484] Fix | Delete
k.scrub!
[485] Fix | Delete
v.force_encoding(enc)
[486] Fix | Delete
v.scrub!
[487] Fix | Delete
end
[488] Fix | Delete
ary
[489] Fix | Delete
end
[490] Fix | Delete
[491] Fix | Delete
private
[492] Fix | Delete
=begin command for WEB_ENCODINGS_
[493] Fix | Delete
curl https://encoding.spec.whatwg.org/encodings.json|
[494] Fix | Delete
ruby -rjson -e 'H={}
[495] Fix | Delete
h={
[496] Fix | Delete
"shift_jis"=>"Windows-31J",
[497] Fix | Delete
"euc-jp"=>"cp51932",
[498] Fix | Delete
"iso-2022-jp"=>"cp50221",
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function