[ruby-core:93395] [Ruby trunk Bug#11915] File.read reading string starting with | executes it.
From:
merch-redmine@...
Date:
2019-06-27 22:51:47 UTC
List:
ruby-core #93395
Issue #11915 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
This was fixed in Ruby 2.6:
```
$ ruby26 -e 'File.read "|/bin/ls"'
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `read': No such file or directory @ rb_sysopen - |/bin/ls (Errno::ENOENT)
```
----------------------------------------
Bug #11915: File.read reading string starting with | executes it.
https://bugs.ruby-lang.org/issues/11915#change-78932
* Author: yxhuvud (Linus Sellberg)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.1.5p273
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
```ruby
puts File.read "|/bin/ls"
[output of executing ls]
=> nil
```
This is quite surprising behaviour.
It is one thing that some of the `.open` methods actually can execute stuff, but a method named 'read' should not behave like that.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>