Skip to content

Commit

Permalink
Read in binary mode to get rid of invalid byte sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Mar 6, 2023
1 parent fbeb247 commit 38de3d1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions net-http.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 38de3d1

Please sign in to comment.