Граф коммитов

6676 Коммитов

Автор SHA1 Сообщение Дата
kazu 8b9a3eaba6 lib/erb.rb: Add uplevel to warn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-24 08:54:19 +00:00
k0kubun cc777d09f4 erb.rb: deprecate safe_level of ERB.new
Also, as it's in the middle of the list of 4 arguments, 3rd and 4th arguments
(trim_mode, eoutvar) are changed to keyword arguments.
Old ways to specify arguments are deprecated and warned now.

bin/erb: deprecate -S option.

We'll remove all of deprecated ones at Ruby 2.7+.

enc/make_encmake.rb: stopped using deprecated interface
ext/etc/mkconstants.rb: ditto
ext/socket/mkconstants.rb: ditto
sample/ripper/ruby2html.rb: ditto
spec/ruby/library/erb/defmethod/def_erb_method_spec.rb: ditto
spec/ruby/library/erb/new_spec.rb: ditto
test/erb/test_erb.rb: ditto
test/erb/test_erb_command.rb: ditto
tool/generic_erb.rb: ditto
tool/ruby_vm/helpers/dumper.rb: ditto
tool/transcode-tblgen.rb: ditto
lib/rdoc/erbio.rb: ditto
lib/rdoc/generator/darkfish.rb: ditto

[Feature #14256]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-22 13:28:25 +00:00
hsbt 7619cb3d7d Merge RubyGems 2.7.6 from upstream.
It fixed some security vulnerabilities.

  http://blog.rubygems.org/2018/02/15/2.7.6-released.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16 08:08:06 +00:00
marcandre b16eaf8632 lib/ostruct.rb: Use `FrozenError` instead of `RuntimeError`.
Patch by Yuuji Yaginuma. [Fixes GH-1808]

In other classes, `FrozenError` will be raised if change the frozen
object.
In order to match the behavior, I think that `FrozenError` should
use in `OpenStruct`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 23:52:30 +00:00
marcandre d3513d313e lib/matrix.rb: Document deprecated methods [#12032] [doc] [ci-skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 23:47:49 +00:00
hsbt 7112c6a1c1 Merge RubyGems-2.7.5 from upstream.
Please see its details: http://blog.rubygems.org/2018/02/06/2.7.5-released.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 02:58:35 +00:00
normal 3474d5c306 net/http: fix documentation for HTTP connection reuse
Thanks to Paul Kuruvilla <rohitpaulk@gmail.com> for the patch

* lib/net/http.rb: fix documentation for HTTP connection reuse
  [ruby-core:84815] [Bug #14349]

From: Paul Kuruvilla <rohitpaulk@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30 18:32:40 +00:00
normal 7830a950ef net/pop: make modified strings mutable
Thanks to Michael Zimmerman for the bug report

* lib/net/pop.rb: make modified strings mutable
  [ruby-core:85210] [Bug #14416]
* test/net/pop/test_pop.rb: new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-30 00:22:22 +00:00
normal 26b3dc4922 uri/common: reduce allocations and retained objects
Thanks to Sam Saffron for this patch, it shows
a nice reduction which affects many web applications:

  require 'memory_profiler'

  MemoryProfiler.report do
    require 'uri'
  end.pretty_print

Before:

Total allocated: 986643 bytes (15159 objects)
Total retained:  246370 bytes (2532 objects)

After:

Total allocated: 926903 bytes (13665 objects)
Total retained:  208570 bytes (1587 objects)

* lib/uri/common.rb: reduce allocations and retained objects
  [ruby-core:85161] [Feature #14410]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-28 21:07:13 +00:00
nobu db1de35a31 optparse.rb: froze string literals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-26 03:41:04 +00:00
nobu 429e2abfad optparse.rb: literal newline
* lib/optparse.rb (OptionParser#summarize): use literal newline to
  join option summaries as IO#puts does, not the special gloval
  variable $/.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-25 01:48:41 +00:00
ko1 f8fa8dd9de revert r62032 because it refers to a undefined variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-25 00:42:08 +00:00
nobu 3010d5eeb9 optparse.rb: literal newline
* lib/optparse.rb (OptionParser#summarize): use literal newline to
  join option summaries as IO#puts does, not the special gloval
  variable $/.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24 23:17:20 +00:00
nobu 7184e03eb2 mkmf.rb: werror on mswin
* lib/mkmf.rb (MakeMakefile#try_ldflags): enable warning checking
  on mswin, link.exe warns -l options but does not fail.
  [Bug #13069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-24 08:25:36 +00:00
nobu 4f03a239dc mkmf.rb: ignore linker warnings
* lib/mkmf.rb (try_ldflags): ignore linker warnings.  they cause
  unexpected failures on OpenBSD.  [ruby-core:78827] [Bug #13069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-22 12:34:51 +00:00
kazu 814daf855e Fix warning
``lib/net/protocol.rb:214: warning: `*' interpreted as argument prefix``

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19 12:15:56 +00:00
nobu 456dc174b6 resolv.rb: NUL hosts
* lib/resolv.rb (Resolv::Hosts::DefaultFileName): fallback to NUL
  device when Win32::Resolv.get_hosts_path() returned nil, to get
  rid of TypeError in lazy_initialize.
  [ruby-core:84907] [Bug #14369]  [Fix GH-1791]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 03:09:39 +00:00
nobu fa5870b9c4 resolv: use safe navigation operator
* lib/resolv.rb (each_address): use safe navigation operator to
  avoid extra hash lookups, as well as each_name since r56890.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 02:44:50 +00:00
normal f729089f44 logger: use safe navigation operator
Saves a few hundred bytes of bytecode in a frequently loaded module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 00:52:01 +00:00
normal 7db24a6269 net/http: use writev for HTTP chunked request bodies
This reduces both user and system CPU time for large
uploads with dynamically-generated request bodies.

              user     system      total        real
before:   0.393334   1.580000   1.973334 (  1.971066)
after:    0.223334   0.976666   1.200000 (  1.198514)

------
require 'socket'
require 'net/http'
require 'benchmark'
nr = 1024 * 1024 * 1024
s = TCPServer.new('127.0.0.1', 0)
addr = s.addr
at_exit { Process.waitall }
fork do
  c = s.accept
  # not exactly accurate but fast
  IO.copy_stream(c, '/dev/null', nr + 500000)
  begin
    buf = c.readpartial(16384)
    tmp = ''
    until buf.end_with?(-"0\r\n\r\n")
      buf << c.readpartial(16384, tmp)
    end
  rescue EOFError
  end
  c.write "HTTP/1.1 201 Created\r\nConnection:close\r\n\r\n"
  c.close
end
r, w = IO.pipe
fork do
  r.close
  IO.copy_stream('/dev/zero', w, nr)
  w.close
end
w.close
Net::HTTP.start(addr[3], addr[1]) do |http|
  put = Net::HTTP::Put.new('/dev0/foo')
  put['Content-Type'] = 'application/content-type'
  put['Transfer-Encoding'] = 'chunked'
  put.body_stream = r
  puts(Benchmark.measure { http.request(put) })
end
------

* lib/net/http/generic_request.rb (write): use multi-arg write
* lib/net/protocol.rb (write): support multi-arg
  (write0): ditto
  [ruby-core:84845] [Feature #14339]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-14 02:44:53 +00:00
kazu 7994269c14 Add `103 Early Hints` to `Net::HTTP::STATUS_CODES` [ci skip]
Update by `ruby lib/net/http/status.rb | sponge lib/net/http/status.rb`

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-12 00:16:59 +00:00
stomar 3b51e3a11f matrix.rb: add Matrix#antisymmetric?
* lib/matrix.rb: add Matrix#antisymmetric?.
  Proposed by Yilo (@yiloo). Patch by Marcus Stollsteimer (@stomar).
  [Fix GH-1788]
* spec/ruby/library/matrix/antisymmetric_spec.rb: add specs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 19:36:30 +00:00
naruse 9e677261a9 Mock fetching data from real DNS [Feature #14340]
This test just tests MDNS#each_address method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-11 18:26:49 +00:00
normal 436eef270d net/http: clear compressed chunk after decompression
We no longer need the compressed data once the inflate block is
called; so clear it ASAP to reduce memory overhead.  This is a
small chunk, so it only saves a few hundred kilobytes with the
script below.

before:        RssAnon:     5976 kB
 after:        RssAnon:     5564 kB
------
require 'net/http'
require 'zlib'
response_gz = ARGV.shift or abort "#$0 TEMPORARY_FILE"

 # pre-create response since compressing is slower than decompressing
unless File.readable?(response_gz)
  nr = 16384 * 2
  buf = ((0..255).map(&:chr).join * 128)
  File.open(response_gz, 'wb') do |fp|
    gzip = Zlib::GzipWriter.new(fp)
    nr.times { gzip.write(buf) }
    gzip.close
  end
  buf.clear
end
response_gz = File.open(response_gz)

s = TCPServer.new('127.0.0.1', 0)
pid = fork do
  c = s.accept
  c.readpartial(16384).clear
  c.write("HTTP/1.1 200 OK\r\n" \
          "Content-Length: #{response_gz.stat.size}\r\n" \
          "Content-Encoding: gzip\r\n" \
          "Accept-Ranges: bytes\r\n" \
          "\r\n")
  IO.copy_stream(response_gz, c)
  c.close
end

addr = s.addr
Net::HTTP.start(addr[3], addr[1]) do |http|
  http.request_get(-'/') do |res|
    res.read_body(&:clear)
  end
end
puts File.readlines(-'/proc/self/status').grep(/RssAnon/)[0]
Process.waitpid2(pid)
------
* lib/net/http/response.rb (inflate_adapter): clear compressed_chunk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 10:23:27 +00:00
normal e1dd1fc35c open-uri: clear string after buffering
Since r58846 (in Ruby 2.5), it is safe to clear the string
yielded to Net::HTTPResponse#read_body methods.  This
reduces malloc garbage (anonymous RSS) using the Linux-only
script below:

before:  user     system      total        real
      0.030000   0.250000   0.280000 (  0.280511)
    RssAnon:	   60240 kB

 after:  user     system      total        real
      0.050000   0.223333   0.273333 (  0.273118)
    RssAnon:	    6676 kB

------
  # warning this script requires 1G free space for buffering
require 'open-uri'
require 'socket'
require 'benchmark'

s = TCPServer.new('127.0.0.1', 0)
len = 1024 * 1024 * 1024
buf = ((0..255).map(&:chr).join * 128)
nr = len / buf.size
pid = fork do
  c = s.accept
  c.readpartial(16384).clear
  c.write("HTTP/1.1 200 OK\r\n" \
	  "Content-Length: #{len}\r\n" \
          "Content-Type: application/octet-stream\r\n" \
          "\r\n")
  buf.freeze # speeds up IO#write slightly
  nr.times { c.write(buf) }
  c.close
end

addr = s.addr
open("http://#{addr[3]}:#{addr[1]}/", "rb") do |fp|
  bm = Benchmark.measure do
    while fp.read(16384, buf)
    end
  end
  puts bm
end
puts File.readlines("/proc/#$$/status").grep(/RssAnon/)[0]
Process.waitpid2(pid)
------

* lib/open-uri.rb: clear string yielded by Net::HTTPResponse#read_body
  [ruby-core:84662] [Feature #14320]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 01:11:33 +00:00
normal b02fc0f9fe net/protocol: read directly into rbuf if it's empty
There's no need to allocate a temporary string when @rbuf is
empty, we can use it as the read_nonblock destination buffer to
save both allocation overhead and avoid a later memcpy.

This results in a halving user CPU time and tiny memory
reduction with the script below:

             user     system      total        real
before   0.603333   0.539999   1.143332 (  1.143347)
       RssAnon:     5624 kB

after    0.283334   0.560000   0.843334 (  0.846072)
       RssAnon:     5592 kB

------
require 'net/http'
require 'benchmark'
s = TCPServer.new('127.0.0.1', 0)
len = 1024 * 1024 * 1024 * 2
pid = fork do
  c = s.accept
  c.readpartial(16384).clear
  c.send("HTTP/1.0 200 OK\r\nContent-Length: #{len}\r\n\r\n", Socket::MSG_MORE)
  IO.copy_stream('/dev/zero', c, len)
  c.close
end

addr = s.addr
Net::HTTP.start(addr[3], addr[1]) do |http|
  http.request_get('/') do |res|
    puts(Benchmark.measure { res.read_body(&:clear) })
  end
end
puts File.readlines("/proc/self/status").grep(/RssAnon/)[0]
Process.waitpid2(pid)
------

* lib/net/protocol.rb (rbuf_fill): avoid allocation if rbuf is empty
  [ruby-core:84678] [Feature #14326]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 00:34:47 +00:00
normal 816efa9ae1 net/protocol: use binary string buffers
Not an encoding expert, but this seems necessary for the next
change.  All of the IO#read, IO#read_nonblock and related
methods will return a binary string when given a length
argument; so anything appended to these buffers via <<
will be binary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 00:34:42 +00:00
stomar bb8f6ac0fe lib/scanf.rb: [DOC] fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 17:49:46 +00:00
normal 0d63d4eee6 Revert "net/protocol: use binary string buffers"
Oops, not ready, yet (will work on this tomorrow :x).
This reverts commit r61638

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 09:23:43 +00:00
normal e56d34001f net/ftp: fix FrozenError in BufferedSocket
I noticed this bug while working on something else with
RUBYOPT=-d on, existing test cases all passed with it.

Note: I use String.new because it is the local style, here,
I prefer +'' (or ''.b, for a future commit)

* lib/net/ftp.rb (BufferedSocket#read): use String.new
* test/net/ftp/test_buffered_socket.rb (test_read_nil): new test
  [ruby-core:84675] [Bug #14323]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 09:21:35 +00:00
normal 7d34bdb81d net/protocol: use binary string buffers
Not an encoding expert, but this seems necessary for the next
change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 09:21:12 +00:00
kazu 660740a75d Update Status Code
see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 04:55:07 +00:00
kazu 34cd43aca9 Add 103 Early Hints
see https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 04:55:06 +00:00
kazu c4e5930f9d Specify frozen_string_literal: true
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-06 04:55:05 +00:00
normal d9beb7690f net/protocol: optimize large read case
There are several places where rbuf_consume is called with
@rbuf.size as its length arg; simplify that case by avoiding
the slow String#slice! operation in favor of a lightweight
replacement.

The following script exhibits reduced memory usage and
runtimes using the time(1) command:

	2.9s =>  2.6s
	70MB => 12 MB

---------
require 'net/http'
require 'digest/md5'
Thread.abort_on_exception = true
s = TCPServer.new('127.0.0.1', 0)
len = 1024 * 1024 * 1024
th = Thread.new do
  c = s.accept
  c.readpartial(16384)
  c.write("HTTP/1.0 200 OK\r\nContent-Length: #{len}\r\n\r\n")
  IO.copy_stream('/dev/zero', c, len)
  c.close
end

addr = s.addr
Net::HTTP.start(addr[3], addr[1]) do |http|
  http.request_get('/') do |res|
    dig = Digest::MD5.new
    res.read_body { |buf|
      dig.update(buf)
      # String#clear is important to reduce malloc overhead,
      # but most Ruby programmers don't do this :<
      buf.clear
    }
    puts dig.hexdigest
  end
end
----------

* lib/net/protocol (rbuf_consume): optimize for @rbuf.size == len
  [Feature #14268]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 02:22:23 +00:00
shyouhei f03146dd70 int (*)(void) is incompatible with void*
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:41:42 +00:00
ko1 fb112a8c4d fix reset order.
* lib/rdoc/test_case.rb (setup): call `RDoc::Markup::PreProcess.reset`
  at the end of `setup` method.
  `RDoc::RDoc.new` requires `rdoc/generator/darkfish`
  and requires `rdoc/tom_doc.rb` at last. It add post_proecssor
  (at `add_post_processor`) and it fails
  `TestRDocMarkupPreProcess#test_class_post_process`.
  This issue occured only with sorted tests by alphabetical order.
  `make test-all TESTS='rdoc/test_rdoc_markup_pre_process.rb --test-order=alpha`)
  We can observe this failure with parallel test only a few times.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-31 00:06:34 +00:00
nobu d83e02017e drb: use \A and \z
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-30 12:10:43 +00:00
ko1 c39bdb798d `$SAFE` as a process global state. [Feature #14250]
* vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to
  `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state.

* vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc`
  objects don't need to keep `$SAFE` at the creation.
  Also make `is_from_method` and `is_lambda` as 1 bit fields.

* cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation.

* eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access
  `vm->safe_level_` directly.

* eval_jump.c: End procs `END{}` doesn't keep `$SAFE`.

* proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c.

* safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes.

* safe.c (safe_setter): use `rb_set_safe_level()`.

* thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`.
  It should be obsolete.

* transcode.c (load_transcoder_entry): `rb_safe_level()` only returns
  0 or 1 so that this check is not needed.

* vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc.

* vm.c (rb_proc_create): renamed to `proc_create`.

* vm.c (rb_proc_dup): moved from proc.c.

* vm.c (vm_invoke_proc): do not need to set and restore `$SAFE`
  for `Proc#call`.

* vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer
  meaning.

* lib/drb/drb.rb: restore `$SAFE`.

* lib/erb.rb: restore `$SAFE`, too.

* test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests.

* test/rubygems/test_gem.rb: do not set `$SAFE = 1`.

* bootstraptest/test_proc.rb: catch up this change.

* spec/ruby/optional/capi/string_spec.rb: ditto.

* test/bigdecimal/test_bigdecimal.rb: ditto.

* test/fiddle/test_func.rb: ditto.

* test/fiddle/test_handle.rb: ditto.

* test/net/imap/test_imap_response_parser.rb: ditto.

* test/pathname/test_pathname.rb: ditto.

* test/readline/test_readline.rb: ditto.

* test/ruby/test_file.rb: ditto.

* test/ruby/test_optimization.rb: ditto.

* test/ruby/test_proc.rb: ditto.

* test/ruby/test_require.rb: ditto.

* test/ruby/test_thread.rb: ditto.

* test/rubygems/test_gem_specification.rb: ditto.

* test/test_tempfile.rb: ditto.

* test/test_tmpdir.rb: ditto.

* test/win32ole/test_win32ole.rb: ditto.

* test/win32ole/test_win32ole_event.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28 20:09:24 +00:00
k0kubun 9006d059f4 erb.rb: let's remove constant deprecated at 2.5
(r59497).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28 05:07:16 +00:00
k0kubun c46d3de0f5 erb.rb: preserve the behavior for invalid syntax
comment. Fix regression at r58948.

I even don't want to deprecate it because deprecation needs to lex all
embedded Ruby script using Ripper and it would be slow.  So Let me just
keep this behavior of Ruby 2.4. No change is the best compatibility.

This commit stopped using String#-@ because it's harmful for "ambiguous
first argument" warning if we really want to maintain this behavior.

[Bug #14243]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-27 12:40:03 +00:00
mame 571e48b744 proc.c (bind_location): Add Binding#source_location
Fixes #14230

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-26 08:38:35 +00:00
nobu 72ac5986bd irb.rb: fix highlight
* lib/irb.rb (IRB::Irb#eval_input): fix highlight for multiple
  lines exception messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 07:55:25 +00:00
nobu efee0c87c1 fix leaked fds
* lib/rubygems/command.rb (Gem::Command#invoke_with_build_args):
  restore UI and close the created SilentUI.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-25 05:54:27 +00:00
normal 7d10b978c3 webrick 1.4.2
This release removes uses of Kernel#open to avoid unintended
behaviors and make future auditing easier. [Misc #14216]

6 changes since 1.4.1:

      webrick: httpauth requires regular files
      webrick/httpservlet/cgi_runner.rb: remove unnecessary open
      webrick: WEBrick::Log requires path arg when given string
      webrick/httpservlet/*handler: use File.open
      webrick/httputils: note Kernel#open behavior
      webrick/httpservelet/cgi_runner: avoid IO#reopen on pathname

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 08:38:43 +00:00
nobu c03c03cc11 lib/irb.rb: highlight exceptions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 02:26:22 +00:00
nobu 43e64b8585 lib/irb.rb: simplified backtrace filtering
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 01:52:21 +00:00
hsbt 9fe26ef8de Merge rdoc-6.0.1.
It fixes an installation error of activerecord.

  https://github.com/ruby/rdoc/issues/571

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-23 23:33:09 +00:00
sorah daaebaec79 Print backtrace in reverse order on IRB too
[Feature #8861]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-23 18:17:39 +00:00
hsbt 7825e8363d Postponing the Bundler merge.
I faced a big issue about Bundler with ruby core.
  I have no time to resolve it issue before 2.5 final release.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 23:08:05 +00:00
nobu 161f4a511a erb.rb: shadow by keys
* lib/erb.rb (ERB#new_toplevel): shadow already defined local
  variables by block local variabes, not to overwrite them.
  [ruby-core:84390] [Bug #14215]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:08:31 +00:00
hsbt 84e462758d Bump up fileutils-1.0.2
Added `FileUtils::VERSION` const variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 08:00:10 +00:00
normal 0d92f156b6 webrick/httpservelet/cgi_runner: avoid IO#reopen on pathname
IO#reopen seems to behave strangely on Win32 based on the logs
posted by Greg for [Bug #14420].  Lets try to fix the issue by
using File.open explicitly (but not Kernel#open).

* lib/webrick/httpservelet/cgi_runner: use File.open explicitly
  [Bug #14220]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 05:59:11 +00:00
normal f2aa7f409a webrick/httputils: note Kernel#open behavior
I don't know who uses the load_mime_types method; but it is
conceivable that a user would want to read the results of a
command instead of reading a regular file to load MIME types.

None of the WEBrick-related code in Ruby or default/bundled gems
seems to rely on this method; but it is likely 3rd-party code does.

* lib/webrick/httputils.rb (load_mime_types): note Kernel#open behavior
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:08:05 +00:00
normal 1ad355bd53 webrick/httpservlet/*handler: use File.open
This makes future code audits easier.  None of these changes
fix realistic remote code execution vulnerabilities because
we stat(2) before attempting Kernel#open.

* lib/webrick/httpservlet/erbhandler.rb (do_GET): use File.open
* lib/webrick/httpservlet/filehandler.rb (do_GET): use File.open
  (make_partial_content): ditto
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:08:00 +00:00
normal 1989371d10 webrick: WEBrick::Log requires path arg when given string
Allowing a user to specify "| command" via Kernel#open is
nonsensical since we never read from the resultant IO.

* lib/webrick/log.rb (initialize): replace Kernel#open with File.open
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:07:55 +00:00
normal 646b83af2a webrick/httpservlet/cgi_runner.rb: remove unnecessary open
IO#reopen already takes string path names as well as IO objects
(but not "| command" strings)

This makes further auditing for inadvertant code execution
easier.  There's no actual bugfix or behavior change here,
as no external data is passed to cgi_runner.rb.

* lib/webrick/httpservlet/cgi_runner.rb: remove Kernel#open call
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:07:45 +00:00
normal edddc28f62 webrick: httpauth requires regular files
Be sure we do not try to open a pipe to read from, since we care
about mtime in all cases.

* lib/webrick/httpauth/htdigest.rb: use File.open
* lib/webrick/httpauth/htgroup.rb: ditto
* lib/webrick/httpauth/htpasswd.rb: ditto
  [Misc #14216]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:07:39 +00:00
akr bf287424fd open-uri defines URI.open defined as an alias.
open-uri's Kernel.open will be deprecated in future.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 14:15:04 +00:00
hsbt 4525cf2cd5 Merge release version of bundler-1.16.1 from upstream.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 09:22:15 +00:00
sonots 7176eb2df9 * lib/logger.rb (Logger::LogDevice#open_logfile, #create_logfile):
Logger should be able to open only files [Bug #14212]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 05:07:43 +00:00
naruse 0078e40115 raise error if value contains CR/LF in iniheader of initialize_http_header
like r59693, initialize_http_header also should raise error. [Bug #14208]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 12:06:59 +00:00
nobu cdf1b85ae7 Fixed command Injection
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed
  potential command injection by use of Kernel#open.
  [ruby-core:84347] [Bug #14205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 04:25:01 +00:00
nobu e7464561b5 Fixed command Injection
* resolv.rb (Resolv::Hosts#lazy_initialize): fixed potential
  command Injection in Hosts::new() by use of Kernel#open.
  [Fix GH-1777] [ruby-core:84347] [Bug #14205]

From: Drigg3r <drigg3r@yandex.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-20 04:18:31 +00:00
eregon 06c7693c1f Break out of the loop after shutdown in DRbServer
* Patch by @seki:
  https://gist.github.com/seki/ae8bef20238c37c94a91b5461c4bfbdd

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-19 15:40:13 +00:00
normal 74ceabb3b2 webrick 1.4.1 release
* lib/webrick/version.rb: bump version
* lib/webrick/webrick.gemspec: support Ruby 2.3+
  [Bug #14189]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 08:54:30 +00:00
nobu a531c579f8 Requiring pp is not required now [ci skip]
- Followup of https://bugs.ruby-lang.org/issues/14123

From: Prathamesh Sonpatki <csonpatki@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 01:51:53 +00:00
marcandre 4eac6eb373 lib/erb: Update doc [ci-skip] [doc]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 20:15:54 +00:00
normal 9cbb3bd1f2 webrick 1.4.0 release
* lib/webrick/version.rb: change VERSION to 1.4.0
* lib/webrick/webrick.gemspec: require_relative for version,
  update date and contact info
  [Feature #13173]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 20:02:15 +00:00
nagachika 6d3f72e5be Fix a command injection vulnerability in Net::FTP.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 13:41:30 +00:00
naruse 84bade6aa7 Use string instead of regexp
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 06:30:22 +00:00
knu b53ec390d1 Allow empty path components in a URI [Bug #8352]
* generic.rb (URI::Generic#merge, URI::Generic#route_to): Fix a bug
  where a sequence of slashes in the path part gets collapsed to a
  single slash.  According to the relevant RFCs and WHATWG URL
  Standard, empty path components are simply valid and there is no
  special treatment defined for them, so we just keep them as they
  are.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 01:11:28 +00:00
hsbt 283bb70fe0 Bump version to csv-1.0.0 as default gems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13 05:24:01 +00:00
normal aac91cb762 webrick: compile RE correctly for beginning and end match
Using ^ and $ in regexps means we can accidentally get fooled
by "%0a" in HTTP request paths being decoded to newline
characters.  Use \A and \z to match beginning and end-of-string
respectively, instead.

Thanks to mame and hsbt for reporting.

* lib/webrick/httpserver.rb (MountTable#compile):
  use \A and \z instead of ^ and $
* lib/webrick/httpserver.rb (MountTable#normalize): use \z instead of $
* test/webrick/test_httpserver.rb (test_cntrl_in_path): new test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-13 00:38:08 +00:00
eregon ca1c3d41fa Avoid creating a Thread for shutting down a DRbServer
* lib/drb/drb.rb: avoid creating a Thread and call the shutdown logic
  directly. Do not try to kill or join the current Thread.
  Thread.new { stop_service } caused "can't alloc thread (ThreadError)",
  which is shown with Thread.report_on_exception = true.
  [Bug #14171]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 18:43:55 +00:00
kazu 38054f99aa Remove unnecessary `:`
Before:

`.../irb/init.rb:280: warning: :LoadError: cannot load such file -- hoge`

After:

`.../irb/init.rb:280: warning: LoadError: cannot load such file -- hoge`

[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 15:01:07 +00:00
kazu e03ea9c596 Use printf instead of puts and sprintf
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 15:01:04 +00:00
shyouhei f2a91397fd Add uplevel keyword to Kernel#warn and use it
If uplevel keyword is given, the warning message is prepended
with caller file and line information and the string "warning: ".
The use of the uplevel keyword makes Kernel#warn format output
similar to how rb_warn formats output.

This patch modifies net/ftp and net/imap to use Kernel#warn
instead of $stderr.puts or $stderr.printf, since they are used
for printing warnings.

This makes lib/cgi/core and tempfile use $stderr.puts instead of
warn for debug logging, since they are used for debug printing
and not for warning.

This does not modify bundler, rubygems, or rdoc, as those are
maintained outside of ruby and probably wish to remain backwards
compatible with older ruby versions.

rb_warn_m code is originally from nobu, but I've changed it
so that it only includes the path and lineno from uplevel
(not the method), and also prepends the string "warning: ",
to make it more similar to rb_warn.

From: Jeremy Evans code@jeremyevans.net
Signed-off-by: Urabe Shyouhei shyouhei@ruby-lang.org


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:56:25 +00:00
k0kubun 4fe2ca38c1 irb/init.rb: make sure ARGV refers to toplevel one
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:32:37 +00:00
k0kubun da1ba13714 irb.rb: preserve ARGV on binding.irb
This is not perfectly good solution (at least we don't want to have ARGV
as default value of `argv` argument), but unfortunately IRB.setup and
IRB.parse_opts are public methods and we can't make breaking change to
those methods.

We may deprecate using them and then make them private in the future,
but the removal should not be in Ruby 2.5. So I kept their interface for
now.

[Bug #14162] [close GH-1770]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:25:16 +00:00
hsbt 8d1d4e3164 Bump version to fileutils-1.0.1.
Update source code url metadata on rubygems.org.
  [Feature #13197][ruby-core:79455]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 10:57:58 +00:00
hsbt 91df3e9b74 Bump version to fileutils-1.0.0 as default gems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 09:01:34 +00:00
hsbt 84db29cea1 Ignore gemspec under the lib directory for documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 08:34:13 +00:00
hsbt a1a20cfaa2 Merge 1-16-stable branch of bundler.
It's rc version for bundler-1.16.1. I'm going to update it version
  after official release from bundler team.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 06:15:44 +00:00
hsbt 93880b4aa3 Bump version to scanf-1.0.0 as default gems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 08:18:01 +00:00
mame 612af3b7cb lib/pp.rb: remove alias for suppressing a redefinition warning.
Because there is now the same guard in prelude.rb (alias pp pp).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 04:46:57 +00:00
hsbt 2d86fe2a55 Bump version to cmath-1.0.0 as default gems.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 03:27:47 +00:00
usa 61045e037e bccwin is no longer supported
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 02:30:42 +00:00
usa 4ed018d947 depend on win32.h on Windows
* lib/mkmf.rb (depend_rules): all objs should depend on win32.h on Windows.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 02:30:21 +00:00
hsbt ef839356db Ignore to generate documentation for template files of bundler.
[Bug #14163][ruby-core:84141]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-11 01:04:46 +00:00
normal 22474d8f96 webrick: allow shutdown after StartCallback
We must to ensure the @status ivar is set to :Running before
running StartCallback, otherwise Webrick::Server#stop will not
change the @status to :Shutdown properly.

Note: I have not been able to reproduce the original issue but
understood at least part of the problem and fixed it with this
commit.  However, the original reporter (Peak Xu) was still able
to reproduce the problem on 1.9.2 p180 on Windows, so I'm not
sure what else might be going on.  Ruby threading and
synchronization primitives have changed a lot since 1.9.2, so
maybe that was fixed elsewhere.

* lib/webrick/server.rb: call StartCallback sooner [Bug #4841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 18:51:56 +00:00
nobu 6d8f47fde1 lib/pp.rb: no rdoc of alias to suppress a warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 08:38:57 +00:00
nobu 60771d1315 pp.rb: rdoc
* lib/pp.rb (pp): move pp alias before its rdoc, not to prevent
  parsing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-08 07:17:34 +00:00
hsbt 25d6a7efab Bump version to rdoc-6.0.0.
There is no changes from rdoc-6.0.0.bebta4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 11:08:00 +00:00
naruse ed48bfa5e8 Append "//" if empty host for file or postgres URI
https://url.spec.whatwg.org/#url-serializing
> Otherwise, if url’s host is null and url’s scheme is "file", append "//" to output.

URL spec doesn't says anything about postgres, but assume the same thing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 15:09:41 +00:00
akr add309c496 Replace Kernel#pp after PP class is defined.
Avoid a race condition which a context switch
occur after replacing Kernel#pp but before
defining PP class.

Following patch, inserting sleep, makes
this problem reproducible.

```
Index: lib/pp.rb
===================================================================
--- lib/pp.rb	(revision 60960)
+++ lib/pp.rb	(working copy)
@@ -26,6 +26,7 @@ module Kernel
   end
   undef __pp_backup__ if method_defined?(:__pp_backup__)
   module_function :pp
+  sleep 1 # thread context switch
 end
 
 ##
```

With the above patch, "uninitialized constant Kernel::PP" can
happen as as follows.

```
% ./ruby -w -Ilib -e '
t1 = Thread.new {
  Thread.current.report_on_exception = true
  pp :foo1
}
t2 = Thread.new {
  Thread.current.report_on_exception = true
  sleep 0.5
  pp :foo2
}
t1.join rescue nil
t2.join rescue nil
'
#<Thread:0x000055dbf926eaa0@-e:6 run> terminated with exception:
Traceback (most recent call last):
	3: from -e:9:in `block in <main>'
	2: from /home/ruby/tst2/ruby/lib/pp.rb:22:in `pp'
	1: from /home/ruby/tst2/ruby/lib/pp.rb:22:in `each'
/home/ruby/tst2/ruby/lib/pp.rb:23:in `block in pp': uninitialized constant Kernel::PP (NameError)
:foo1
```



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 10:48:29 +00:00
nobu 5761093ee1 prelude.rb: suppress redefinition warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 03:54:49 +00:00
mame 4ae87f0ad6 lib/pp.rb (Kernel#pp): Fix a race condition
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 00:41:17 +00:00
mame 23c1fccf83 prelude.rb: Add Kernel#pp, a trigger for lib/pp.rb
[Feature #14123]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-30 01:31:00 +00:00
hsbt e82802070a Merge rubygems-2.7.3.
http://blog.rubygems.org/2017/11/28/2.7.3-released.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-28 22:30:28 +00:00
svn c6fa9664f3 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-27 10:45:27 +00:00
hsbt 5551871086 Merge rdoc-6.0.0.beta4 from upstream.
It version applied `frozen_string_literal: true`

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-27 10:45:24 +00:00
kazu 6d14c47c20 Fix TOCTTOU and avoid to read existing unreadable file
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24 11:00:10 +00:00
nobu 9b48a6aec1 workspace.rb: one more space
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24 05:44:58 +00:00
nobu 8b6e9aa792 workspace.rb: fix SCRIPT_LINES__
* lib/irb/workspace.rb (code_around_binding): `SCRIPT_LINES__`
  values are arrays of lines.  get file and line at once.  moved
  loop-invariant format string.  join without extra strings by
  `$,`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24 05:00:56 +00:00
k0kubun 106c9883e1 irb.rb: show source around binding.irb on start
[Feature #14124] [ruby-dev:50319] [close GH-1764]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24 03:53:27 +00:00
stomar 8692d74b09 lib/set.rb: [DOC] remove empty comments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-22 21:13:51 +00:00
stomar 62191f1cc5 set.rb: improve docs for Set
* lib/set.rb: [DOC] add examples for Set#replace,
  add examples for creating a set from a hash with duplicates,
  simplify and fix style of some other examples, fix typos.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-22 20:58:24 +00:00
kazu 0e7c83e374 [DOC] Fix example result [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20 12:57:08 +00:00
marcandre b1152fab0f lib/matrix: Add hadamard_product/entrywise_product.
Based on a patch by Charley Hutchison. [GH-674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20 02:18:43 +00:00
marcandre 980c0dd360 lib/matrix: Add Matrix{.|#}combine
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20 02:18:34 +00:00
marcandre 62646c8d67 lib/matrix: accept vectors in {h|v}stack
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20 02:18:23 +00:00
marcandre aa95a42190 lib/matrix: Add explicit coercion #to_matrix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-20 02:18:12 +00:00
kazu 859abb7ffb Fix typo in `Timeout` doc [ci skip]
Author: yuuji.yaginuma <yuuji.yaginuma@gmail.com>
https://github.com/ruby/ruby/pull/1760
[Fix GH-1760]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 15:08:03 +00:00
knu 8d7d8d0c7f Add examples to Set documentation [ci skip]
GitHub PR:    https://github.com/ruby/ruby/pull/1752 [Fix GH-1752]
Submitted by: @Ana06 <anamma06@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 09:48:47 +00:00
nobu 25d56ea7b7 tmpdir.rb: merged make_tmpname to create
* lib/tmpdir.rb (Dir::Tmpname#create): try conversion of prefix
  and suffix just once before loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-15 08:02:09 +00:00
marcandre 3527c863be lib/matrix: Remove method catalog [doc] [ci-skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 22:05:44 +00:00
hsbt 3ba9e6b639 Merge rubygems-2.7.2.
This version fixes some setup commands.
  01e797f6aa/History.txt (L3)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 00:42:19 +00:00
stomar 35bd2ad25e http.rb: improve docs
* lib/net/http.rb: [DOC] fix typos and grammar

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 20:13:48 +00:00
hsbt 54e58c947b Merge RubyGems 2.7.1.
* Fix `gem update --system` with RubyGems 2.7+.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-06 02:02:04 +00:00
stomar 71e3a3e8e3 rexml: improve docs
* lib/rexml/entity.rb: [DOC] drop a pointless comment.
  Reported by Michael Gee (mikegee).  [Fix GH-1736]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02 20:06:38 +00:00
hsbt 9e475eef86 Merge release version of Rubygems 2.7.0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02 04:25:37 +00:00
hsbt be7b592912 Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0.
  * common.mk: rspec examples of bundler-1.16.0 needs require option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01 23:29:38 +00:00
normal 3b92c63158 webrick/httpresponse: minor cleanups to reduce memory use
I never knew "format" was a global method alias for "sprintf";
so it was confusing to me.  Normally, one would use "sprintf"
since it's also available in many other languages, but
Integer#to_s avoids parsing a format string so it's less
bug-prone.

Furthermore, favor string interpolation over String#<< since it
is easier for the VM to optimize memory allocation (as in r60320).
Interpolation also reduces method calls and memory overhead
for inline method cache.

Finally, ensure we clear all short-lived buffers for body
responses.  A similar change was made and measured for Net::*
in r58840 showing a large memory reduction on some workloads.

* webrick/httpresponse.rb (send_body_io): favor String#to_s,
  reduce method calls for String#<<,
  clear `buf' when done,
  avoid extra String#bytesize calls

* (send_body_string): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 01:37:37 +00:00
normal bb88b1aab8 webrick: support Proc objects as body responses
* lib/webrick/httpresponse.rb (send_body): call send_body_proc
  (send_body_proc): new method
  (class ChunkedWrapper): new class

* test/webrick/test_httpresponse.rb (test_send_body_proc): new test
  (test_send_body_proc_chunked): ditto
  [Feature #855]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-30 23:56:44 +00:00
stomar cd63bec1ed lib/set.rb: improve docs for Set#===
* lib/set.rb: [DOC] improve description and examples for Set#===.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 20:59:33 +00:00
naruse 3acc0ba1d8 Host header should add branckets to IPv6 address [Bug #12642]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 15:29:36 +00:00
nobu 7ed3aae2fe securerandom.rb: fix an example of choose [ci skip]
* lib/securerandom.rb (Random::Formatter#choose): [DOC] fix an
  example, `n` is not optional.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 07:28:22 +00:00
marcandre e565c838ce lib/ostruct.rb: Use frozen literals.
Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 18:08:15 +00:00
marcandre 013dcf08a1 lib/weakref: Remove incorrect example [DOC] [Bug #14031]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 18:08:00 +00:00
normal 752faf4fb4 net/http: use require_relative to reduce syscalls
require_relative speeds up loading of files by reducing path
lookups.  On a clean install with RubyGems-enabled,
"ruby -rnet/http -e exit" shows a reduction in failed open(2)
syscalls from 410 to 350 (x86-64 GNU/Linux).

I could not measure a time difference on my Linux-based
machines, however this should be noticeable to users of other
kernels with worse syscall and VFS performance than Linux.

Further use of require_relative will reduce lookups in other
places.

* lib/net/http.rb: use require_relative
  [ruby-core:78285] [Feature #12973]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 01:22:08 +00:00
kou 5e64882123 rss itunes: fix a bug that <itunes:explicit> value isn't fully supported
Fix GH-1725

<itunes:explicit> accepts "explicit", "yes", "true", "clean", "no" and
"false" as valid values.

Here is the <itunes:explicit>'s description in
https://help.apple.com/itc/podcasts_connect/#/itcb54353390:

> The <itunes:explicit> tag indicates whether your podcast contains
> explicit material. You can specify the following values:
>
>   * Yes | Explicit | True. If you specify yes, explicit, or true,
>     indicating the presence of explicit content, the iTunes Store
>     displays an Explicit parental advisory graphic for your podcast.
>
>   * Clean | No | False. If you specify clean, no, or false, indicating
>     that none of your podcast episodes contain explicit language or
>     adult content, the iTunes Store displays a Clean parental
>     advisory graphic for your podcast.

I don't know whether <itunes:explicit> value is case sensitive or
insensitive. But the current implementation is case insensitive.

Reported by Valerie Woolard Srinivasan. Thanks!!!


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 16:03:57 +00:00
knu 8c90432af7 Add `Set#reset`
This method resets the internal state of a set after modification to
existing elements, reindexing and deduplicating them. [Feature #6589]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 12:25:34 +00:00
hsbt 6693e3e723 Fixed misspelling words.
These are detected by https://github.com/client9/misspell

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 11:27:06 +00:00
knu 0fcac8f1a3 Avoid use of `self.class.new(self)` in Set#collect!
That prevents infinite recursion when a subclass of Set uses
`collect!` in its constructor.

This should fix [Bug #12437].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 17:03:40 +00:00
knu c1c527c290 Fix comparison methods of Set to check if `@hash` is actually comparable
This should fix comparison of rbtree backed SortedSet instances.
[Bug #12072]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:28:52 +00:00
naruse dcea9198a9 Introduce Net::HTTP#min_version/max_version [Feature #9450]
Set SSL minimum/maximum version.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:25:22 +00:00
akr 6cba29b422 less random generations in Random::Formatter#choose.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:12:46 +00:00
knu 8daa6985dc Use a mutex to make SortedSet.setup thread-safe
This should fix [Bug #13735].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:57:32 +00:00
knu 76e3825376 Remove redundant use of module_eval
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:57:26 +00:00
knu 3090169c9b Allow a SortedSet to be frozen and still functional [Bug #12091]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:38:38 +00:00
akr b867882a1c SecureRandom.alphanumeric implemented.
[ruby-core:68098] [Feature #10849] proposed by Andrew Butterfield.

SecureRandom.choose and SecureRandom.graph is not included.
(The implementation has SecureRandom.choose but it is private.)

I feel the method name, SecureRandom.choose, doesn't represent
the behavior well.

The actual use cases of SecureRandom.graph is not obvious.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:21:26 +00:00
k0kubun 774b42d643 erb.rb: specify frozen_string_literal: true
for compilation performance.

$ ruby ./benchmark/driver.rb -e "trunk::/Users/k0kubun/.rbenv/versions/trunk/bin/ruby;modified::/Users/k0kubun/.rbenv/versions/modified/bin/ruby" -d ./benchmark -p app_erb

-----------------------------------------------------------
benchmark results:
Execution time (sec)
name    trunk   modified
app_erb 1.911      1.885

Speedup ratio: compare with the result of `trunk' (greater is better)
name    modified
app_erb    1.014

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:02:46 +00:00
kazu dabdec31e4 Use caller with length to reduce unused strings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:40:03 +00:00
hsbt 52a275ee79 Removed obsoleted safe level checks on irb.
https://github.com/ruby/ruby/pull/1713

  Patch by @y-yagi [fix GH-1713]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 14:11:08 +00:00
hsbt db590b5d59 Fixed unexpected behavior of `Resolv::MDNS#each_address` when given ".local" address.
https://github.com/ruby/ruby/pull/1425

  Patch by @elct9620 [fix GH-1484]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 13:58:31 +00:00
knu c2db917b3d Import ipaddr 1.2.0
- Add IPAddr#prefix
- Add IPAddr#loopback?
- Add IPAddr#private? [Feature #11666]
- Add IPAddr#link_local? [Feature #10912]
- Reject invalid address mask [Bug #13399]
- Warn that IPAddr#ipv4_compat and #ipv4_compat? are deprecated [#Bug 13769]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 13:34:19 +00:00
nobu 4bf6a04f49 Fix bug about String#scanf("%a")
* lib/scanf.rb (extract_float, initialize): allow to omit a sign
  on the binary exponent.  [ruby-core:82435] [Bug #13833]
  [Fix GH-1689]

From: tarotaro0 <tarousann11922960@yahoo.co.jp>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 12:34:13 +00:00
knu 49ce3ca374 Make ACL::ACLEntry not suppress IPAddr::InvalidPrefixError
This is because it would be a user error because a pattern containing
a slash shouldn't be a host name pattern but an IP address pattern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 09:53:52 +00:00
akr 3d9453994c lib/open3.rb: accept IO-like object for :stdin_data argument.
Open3.capture3, Open3.capture2, Open3.capture2e accepts
IO-like object for :stdin_data argument.
[ruby-core:80936] [Feature #13527] proposed by janko.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 07:00:58 +00:00
akr a2831955b2 lib/open-uri.rb: accept :encoding option as well as encoding in mode string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 06:22:53 +00:00
hsbt 43e320ba1b Merge rubygems master(ddbf3203f3857649abe95c73edefc7de7e6ecff4).
It fixed: https://github.com/rubygems/rubygems/issues/2041

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 09:03:37 +00:00
hsbt 0242f7ccae Overwrite destination symlink file if `remove_destination` is set.
[Bug #13914][ruby-core:82846] Patch by @mzp
  https://github.com/ruby/fileutils/pull/9

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 07:03:11 +00:00
nobu 90048176cc Make Time.parse respect timezone offset seconds
DateTime.parse handles them correctly, and DateTime.parse.to_time
results in the correct time.  Time.parse doesn't handle them
correctly because Time.zone_offset uses a different regexp that
only considers hours and minutes, not seconds.
[ruby-core:83400] [Bug #14034]

From: Jeremy Evans <code@jeremyevans.net>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 01:03:18 +00:00
normal cda27e1a6d webrick: fix up r60172 and r60210
Thanks to MSP-Greg (Greg L) for helping with this.

* lib/webrick/server.rb (start_thread): properly fix non-local return
  introduced in r60208 and r60210

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 23:34:02 +00:00
normal 834c252e5e webrick: fix up r60172 and r60208
Thanks to MSP-Greg (Greg L) for helping with this.

* lib/webrick/server.rb (start_thread): fix non-local return
  introduced in r60208

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 23:23:33 +00:00
normal 3b1db7d319 webrick: fix up r60172 and revert r60189
Thanks to MSP-Greg (Greg L) for helping with this.

* lib/webrick/server.rb (start_thread): ignore ECONNRESET, ECONNABORTED,
  EPROTO, and EINVAL on TLS negotiation errors the same way they
  were ignored before r60172 in the accept_client method of the
  main acceptor thread.
  [Bug #14013] [Bug #14005]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-18 21:45:34 +00:00
nobu 593d978646 tempfile.rb: [DOC] all arguments [ci skip]
* lib/tempfile.rb (Tempfile.create): mention the other arguments
  too.  [ruby-core:83321] [Misc #14019]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 12:40:00 +00:00
kazu 73d128ff2c Fix warning: assigned but unused variable
[Bug #14020][ruby-core:83313]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 11:58:51 +00:00
mame 16b6fe17a3 Suppress leak of file descriptors
`Bundler.ui=` in `Gem::TestCase#setup` creates `Bundler::UI::RGProxy`
which inherites `::Gem::SilentUI` whose `initialize` opens `/dev/null`,
and assigns it to `Gem::DefaultUserInteraction.ui`.
After that, `Gem::TestCase#setup` forces to overwrite
`Gem::DefaultUserInteraction.ui` with a mock.
Thus, the instance of `::Gem::SilentUI` is not closed, which leads to
the leak.

This commit keeps `Gem::DefaultUserInteraction.ui` and manually close it
in `teardown`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 07:41:03 +00:00
nobu 6b4cd8a996 Layout fixes in rdoc of lib/tempfile.rb [ci skip]
RDoc doesn't understand an asterisk inside the plus markers. Moving them
out of the markers looks better.
[Fix GH-1716]

From:    Herwin Weststrate <herwinw@herwinw.nl>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-16 23:11:40 +00:00
normal 525ebb862e webrick: fix up r60172
By making the socket non-blocking in r60172, TLS/SSL negotiation
via the SSL_accept function must handle non-blocking sockets
properly and retry on SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE.
OpenSSL::SSL::SSLSocket#accept cannot do that properly with a
non-blocking socket, so it must use non-blocking logic of
OpenSSL::SSL::SSLSocket#accept_nonblock.

Thanks to MSP-Greg (Greg L) for finding this.

* lib/webrick/server.rb (start_thread): use SSL_accept properly
  with non-blocking socket.
  [Bug #14013] [Bug #14005]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-16 04:33:53 +00:00
normal feafe07874 webrick: do not hang acceptor on slow TLS connections
OpenSSL::SSL::SSLSocket#accept may block indefinitely on clients
which negotiate the TCP connection, but fail (or are slow) to
negotiate the subsequent TLS handshake.  This prevents the
multi-threaded WEBrick server from accepting other connections.

Since the TLS handshake (via OpenSSL::SSL::SSLSocket#accept)
consists of normal read/write traffic over TCP, handle it in the
per-client thread, instead.

Furthermore, using non-blocking accept() is useful for non-TLS
sockets anyways because spurious wakeups are possible from
select(2).

* lib/webrick/server.rb (accept_client): use TCPServer#accept_nonblock
  and remove OpenSSL::SSL::SSLSocket#accept call
* lib/webrick/server.rb (start_thread): call OpenSSL::SSL::SSLSocket#accept
* test/webrick/test_ssl_server.rb (test_slow_connect): new test
  [ruby-core:83221] [Bug #14005]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-12 18:50:07 +00:00
hsbt 500f15e507 Merge rubygems-2.6.14 changes.
It fixed http://blog.rubygems.org/2017/10/09/unsafe-object-deserialization-vulnerability.html

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 08:58:22 +00:00
hsbt 6d86ee593a Removed obsoleted test for RubyToken.
[Bug #13991][ruby-core:83188] Patch by MSP-Greg.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 04:54:49 +00:00
svn f05f1ecb2d * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 02:01:01 +00:00
hsbt db6c51ec4f Merge rdoc-6.0.0.beta3.
* It version introduced did you mean? feature for ri command:
    https://github.com/ruby/rdoc/pull/533
  * Removed obbsoleted ruby_token.rbb.
    [Bug #13990][ruby-core:83180]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-10 02:01:00 +00:00
normal 4c6335e93b webrick: avoid needless wakeup from IO.select
Since r51231 ("webrick/server.rb: stop immediately"),
there is no need to poll on the @status change every
two seconds.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-09 19:00:22 +00:00
hsbt cb69638dd1 Removed unnecessary json loading.
It causes test fail on http://ci.rvm.jp/results/trunk-test@frontier/101990

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 09:13:03 +00:00
kazu 6064132c42 Remove unnecessary `require 'thread'`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 07:00:01 +00:00
svn 3b1d6fc168 * remove trailing spaces, append newline at EOF.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 01:32:22 +00:00
hsbt c00e84327f Merge rubygems master.
This is RC version of Rubygems 2.7.0.
  688fb7e83c

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 01:32:18 +00:00
nobu 9de6c712b6 No more ubygems in trunk
[Fix GH-1711]
Author:    MSP-Greg <MSP-Greg@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06 00:15:08 +00:00
normal 0d2ab887f3 webrick: avoid unnecessary IO#sync= call
Sockets and pipes are always created with FMODE_SYNC flag
already set (otherwise many things would be broken).

* lib/webrick/server.rb (accept_client): remove unnecessary
  IO#sync= call

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 21:53:54 +00:00
hsbt 5b3d137b1f Fixed broken `bundle gem` command.
This patch is provided by @gyugyu (Yusuke Yagyu)

  * Remove README* entry from no_install that there is no README* files except README.md.tt
  * Rename .travis.yml.tt to travis.yml.tt like gitignore.tt

  [Bug #13975][ruby-dev:50278][fix GH-1710]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 08:32:01 +00:00
hsbt d002f23024 Fixed invalid gemspec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 01:43:47 +00:00
hsbt a6ac6e0098 Followed up [ruby-core:83093]. Update gemspec attributes.
Added metadata for rubygems.org.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-05 01:30:08 +00:00
kazu 5723d9fd34 Use unpack1 instead of unpack and `[0]`
[Feature #13943][ruby-core:83027]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-29 11:00:00 +00:00
naruse c4130b0958 Net::HTTP.new: Support no_proxy parameter [Feature #11195]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-28 10:51:37 +00:00
naruse ec7c76c446 URI::Generic: Separate no_proxy handling
To share with Net::HTTP. see #11195

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-28 10:51:31 +00:00
kazu 8aebd7e9eb Fix exception class [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-27 12:32:57 +00:00
naruse 4f4d724720 Make retries for Net::HTTP configurable [Feature #10674]
by stereobooster
fix https://github.com/ruby/ruby/pull/1654

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-26 14:00:25 +00:00
k0kubun 9d389d6510 erb.rb: drop unreachable method
This seems to be unreachable from first introduction at r21286.

In ERB implementation, `#empty?` is only called for each member of
return value of `String#scan`, and `ERB::Compiler::PercentLine` is never
returned from `String#scan`.

Also, in `ERB::Compiler#compile`, as it's yielded only when stag is nil,
methods called to `ERB::Compiler::PercentLine` object yielded from
`ERB::Compiler::TrimScanner#scan` are only: `#nil?`, `#==`, `to_s`.

Thus `ERB::Compiler::PercentLine#empty?` is never used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-26 11:50:07 +00:00
naruse 56f91c6ec5 HTTPHeader#add_field should allow binary [Bug #13926]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-25 14:28:53 +00:00
hsbt e5e1f904d5 Removed ubygems.rb. rubygems.rb is always loaded now.
* tool/sync_default_gems.rb: removed ubygems.rb from sync target.
  * test/rubygems/test_gem.rb: only enable "-rubygems" option when
    running under the Ruby 1.9.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-24 07:52:25 +00:00
hsbt 1aa4a40d4f Integrate LICENSE file of rubygems to LEGAL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-23 02:24:27 +00:00
eregon 2dd35a7453 Prefer adapting specs to complicating library code
* lib/net/ftp.rb (Net::FTP#initialize): simplify as per
  the original intent.
* spec/ruby/library/net/ftp/initialize_spec.rb: adapt specs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 21:50:14 +00:00
eregon aaf07f7ad5 Adapt tools to follow spec/rubyspec => spec/ruby rename
* [Misc #13792] [ruby-core:82287]
* Prefer test-spec over test-rubyspec in spec/README.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 20:19:54 +00:00
shugo da1b14bcec Add MonitorMinx#mon_locked? and #mon_owned? to check states of objects
Patched by Satoshi "Moris" Tagomori <tagomoris@gmail.com>.  [Fix GH-1699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-20 01:40:53 +00:00
knu 2aee703e7a Alias Set#=== to #include?
* set.rb (Set#===): Added via [Feature #13801] by davidarnold.

Closes #1673.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 08:45:12 +00:00
normal b40a9475db webrick: handle EAGAIN/EWOULDBLOCK on proxy connections
* lib/webrick/httpproxy.rb (do_CONNECT): high-level IO methods
  [ruby-core:82861] [Bug #12130]
  Patch by: Keisuke NISHI

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 08:39:22 +00:00
hsbt 2b86b6f333 Define the MIME type for JSON in WEBrick::HTTPUtils::DefaultMimeTypes.
[Feature #10798][ruby-core:67879]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-19 01:54:28 +00:00
nobu 2635984cf2 fileutils.rb: error at rmdir
* lib/fileutils.rb (rmdir): should not ignore errors first, except
  for parent directories.  [ruby-dev:50236] [Bug #13889]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-16 11:59:47 +00:00
hsbt 274c6180b7 To use github url for gemspec.
[Bug #13906][ruby-core:82817]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-15 23:46:46 +00:00
naruse b2996b30d9 Find.find -> Use Dir.children instead of Dir.entries
Dir.children is available since Feature #11302.
Find.find can use of the new list (having no '.' neither '..' entries),
making now superflous an if statement.

This change can improve the performance of Find.find when the path
has lots of entries (thousands?).

https://bugs.ruby-lang.org/issues/11302
patched by Espartaco Palma <esparta@gmail.com>
https://github.com/ruby/ruby/pull/1697 fix GH-1697
[Feature #13896]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-15 17:00:49 +00:00
naruse 16225d823d include query parameters in Net::HTTP.post
patched by Samuel Giddins <segiddins@segiddins.me>
https://github.com/ruby/ruby/pull/1686 fix GH-1686

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-15 16:53:55 +00:00
mame 6617c41292 lib/webrick/log.rb: sanitize any type of logs
It had failed to sanitize some type of exception messages.  Reported and
patched by Yusuke Endoh (mame) at https://hackerone.com/reports/223363

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 11:16:23 +00:00
hsbt 4d5c414fcc Update gemspec for gem released versions.
* These are dbm, fcntl, io-console, sdbm, stringio, strscan, zlib,
    cmath, scanf.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 02:01:36 +00:00
ko1 9ea2102e57 remove an unused variable (sometimes it fails test).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 01:55:59 +00:00
hsbt a8c632972f Removed needless magic-comment for encodings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-13 09:06:34 +00:00