Project

General

Profile

Feature #11938 ยป 0001-stdlib-avoid-extra-calls-to-eliminate-n-from-Base64.patch

normalperson (Eric Wong), 01/02/2016 05:20 AM

View differences:

ext/psych/lib/psych/visitors/yaml_tree.rb
tag = nil
if binary?(o)
o = [o].pack('m').chomp
o = [o].pack('m0')
tag = '!binary' # FIXME: change to below when syck is removed
#tag = 'tag:yaml.org,2002:binary'
style = Nodes::Scalar::LITERAL
lib/net/http.rb
buf = "CONNECT #{@address}:#{@port} HTTP/#{HTTPVersion}\r\n"
buf << "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m')
credential.delete!("\r\n")
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
buf << "Proxy-Authorization: Basic #{credential}\r\n"
end
buf << "\r\n"
lib/net/http/header.rb
end
def basic_encode(account, password)
'Basic ' + ["#{account}:#{password}"].pack('m').delete("\r\n")
'Basic ' + ["#{account}:#{password}"].pack('m0')
end
private :basic_encode
lib/net/imap.rb
send_command("AUTHENTICATE", auth_type) do |resp|
if resp.instance_of?(ContinuationRequest)
data = authenticator.process(resp.data.text.unpack("m")[0])
s = [data].pack("m").gsub(/\n/, "")
s = [data].pack("m0")
send_string_data(s)
put_string(CRLF)
end
......
if $1
"&-"
else
base64 = [$&.encode(Encoding::UTF_16BE)].pack("m")
"&" + base64.delete("=\n").tr("/", ",") + "-"
base64 = [$&.encode(Encoding::UTF_16BE)].pack("m0")
"&" + base64.delete("=").tr("/", ",") + "-"
end
}.force_encoding("ASCII-8BIT")
end
lib/net/smtp.rb
def base64_encode(str)
# expects "str" may not become too long
[str].pack('m').gsub(/\s+/, '')
[str].pack('m0')
end
IMASK = 0x36
lib/open-uri.rb
target_port = proxy_uri.port
request_uri = target.to_s
if proxy_user && proxy_pass
header["Proxy-Authorization"] = 'Basic ' + ["#{proxy_user}:#{proxy_pass}"].pack('m').delete("\r\n")
header["Proxy-Authorization"] =
'Basic ' + ["#{proxy_user}:#{proxy_pass}"].pack('m0')
end
end
lib/rss/rss.rb
__send__(self.class.xml_getter).to_s
else
_content = content
_content = [_content].pack("m").delete("\n") if need_base64_encode?
_content = [_content].pack("m0") if need_base64_encode?
h(_content)
end
end
lib/securerandom.rb
#
# See RFC 3548 for the definition of base64.
def base64(n=nil)
[random_bytes(n)].pack("m*").delete("\n")
[random_bytes(n)].pack("m0")
end
# SecureRandom.urlsafe_base64 generates a random URL-safe base64 string.
......
#
# See RFC 3548 for the definition of URL-safe base64.
def urlsafe_base64(n=nil, padding=false)
s = [random_bytes(n)].pack("m*")
s.delete!("\n")
s = [random_bytes(n)].pack("m0")
s.tr!("+/", "-_")
s.delete!("=") unless padding
s
lib/webrick/httpauth/digestauth.rb
def generate_next_nonce(req)
now = "%012d" % req.request_time.to_i
pk = hexdigest(now, @instance_key)[0,32]
nonce = [now + ":" + pk].pack("m*").chop # it has 60 length of chars.
nonce = [now + ":" + pk].pack("m0") # it has 60 length of chars.
nonce
end
lib/webrick/httpproxy.rb
if proxy = proxy_uri(req, res)
proxy_request_line = "CONNECT #{host}:#{port} HTTP/1.0"
if proxy.userinfo
credentials = "Basic " + [proxy.userinfo].pack("m").delete("\n")
credentials = "Basic " + [proxy.userinfo].pack("m0")
end
host, port = proxy.host, proxy.port
end
......
if upstream = proxy_uri(req, res)
if upstream.userinfo
header['proxy-authorization'] =
"Basic " + [upstream.userinfo].pack("m").delete("\n")
"Basic " + [upstream.userinfo].pack("m0")
end
return upstream
end
-
    (1-1/1)