Project

General

Profile

Feature #14245 ยป 0001-io.c.patch

shugo (Shugo Maeda), 03/17/2018 11:47 AM

View differences:

NEWS
138 138

  
139 139
=== Compatibility issues (excluding feature bug fixes)
140 140

  
141
* File
142

  
143
  * File.read, File.binread, File.write, File.binwrite, File.foreach,
144
    and File.readlines do not invoke external commands even if the path
145
    starts with the pipe character |.  [Feature #14245]
146

  
141 147
=== Stdlib compatibility issues (excluding feature bug fixes)
142 148

  
143 149
=== C API updates
io.c
7113 7113
		   const convconfig_t *convconfig, mode_t perm)
7114 7114
{
7115 7115
    VALUE cmd;
7116
    const int warn = klass == rb_cFile;
7117
    if ((warn || klass == rb_cIO) && !NIL_P(cmd = check_pipe_command(filename))) {
7118
	if (warn) {
7119
	    rb_warn("IO.%"PRIsVALUE" called on File to invoke external command",
7120
		    rb_id2str(rb_frame_this_func()));
7121
	}
7116
    if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
7122 7117
	return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
7123 7118
    }
7124 7119
    else {
test/ruby/test_io.rb
2196 2196

  
2197 2197
  def test_read_command
2198 2198
    assert_equal("foo\n", IO.read("|echo foo"))
2199
    assert_warn(/invoke external command/) do
2199
    assert_raise(Errno::ENOENT, Errno::EINVAL) do
2200 2200
      File.read("|#{EnvUtil.rubybin} -e puts")
2201 2201
    end
2202
    assert_warn(/invoke external command/) do
2202
    assert_raise(Errno::ENOENT, Errno::EINVAL) do
2203 2203
      File.binread("|#{EnvUtil.rubybin} -e puts")
2204 2204
    end
2205 2205
    assert_raise(Errno::ENOENT, Errno::EINVAL) do