diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-03-06 16:03:15 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-03-06 13:26:34 +0000 |
commit | c8c3431b0a5995d58f97c511ffa0a39e0f19c75e (patch) | |
tree | 91387d3fbb5be64eaeeca9a06329cbde3dc931cf /lib/net | |
parent | fd0a5659cadb49f1640b20896cd750decdbbd701 (diff) |
[ruby/net-http] Read in binary mode to get rid of invalid byte sequence
https://github.com/ruby/net-http/commit/38de3d17a7
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/http/net-http.gemspec | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/net/http/net-http.gemspec b/lib/net/http/net-http.gemspec index a7f122fc0e..459da8650c 100644 --- a/lib/net/http/net-http.gemspec +++ b/lib/net/http/net-http.gemspec @@ -2,9 +2,14 @@ name = File.basename(__FILE__, ".gemspec") version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir| - break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line| - /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1 - end rescue nil + file = File.join(__dir__, dir, "#{name.tr('-', '/')}.rb") + begin + break File.foreach(file, mode: "rb") do |line| + /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1 + end + rescue SystemCallError + next + end end Gem::Specification.new do |spec| |