[rubygems/rubygems] Fix incompatible encodings error
https://github.com/rubygems/rubygems/commit/d478ec403f
This commit is contained in:
parent
21af248f92
commit
50dbe19b68
@ -433,4 +433,18 @@ module Gem
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Gem.rubygems_version >= Gem::Version.new("3.5.23")
|
||||
class Package; end
|
||||
require "rubygems/package/tar_reader"
|
||||
require "rubygems/package/tar_reader/entry"
|
||||
|
||||
module FixFullNameEncoding
|
||||
def full_name
|
||||
super.force_encoding(Encoding::UTF_8)
|
||||
end
|
||||
end
|
||||
|
||||
Package::TarReader::Entry.prepend(FixFullNameEncoding)
|
||||
end
|
||||
end
|
||||
|
@ -228,6 +228,17 @@ class Gem::Package::TarHeader
|
||||
@checksum = oct calculate_checksum(header), 6
|
||||
end
|
||||
|
||||
##
|
||||
# Header's full name, including prefix
|
||||
|
||||
def full_name
|
||||
if prefix != ""
|
||||
File.join prefix, name
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def calculate_checksum(header)
|
||||
|
@ -87,11 +87,7 @@ class Gem::Package::TarReader::Entry
|
||||
# Full name of the tar entry
|
||||
|
||||
def full_name
|
||||
if @header.prefix != ""
|
||||
File.join @header.prefix, @header.name
|
||||
else
|
||||
@header.name
|
||||
end
|
||||
@header.full_name.force_encoding(Encoding::UTF_8)
|
||||
rescue ArgumentError => e
|
||||
raise unless e.message == "string contains null byte"
|
||||
raise Gem::Package::TarInvalidError,
|
||||
|
@ -1218,6 +1218,35 @@ RSpec.describe "bundle install with gem sources" do
|
||||
end
|
||||
end
|
||||
|
||||
describe "when configured path is UTF-8 and a file inside a gem package too" do
|
||||
let(:app_path) do
|
||||
path = tmp("♥")
|
||||
FileUtils.mkdir_p(path)
|
||||
path
|
||||
end
|
||||
|
||||
let(:path) do
|
||||
root.join("vendor/bundle")
|
||||
end
|
||||
|
||||
before do
|
||||
build_repo4 do
|
||||
build_gem "mygem" do |s|
|
||||
s.write "spec/fixtures/_posts/2016-04-01-错误.html"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "works" do
|
||||
bundle "config path #{app_path}/vendor/bundle", dir: app_path
|
||||
|
||||
install_gemfile app_path.join("Gemfile"),<<~G, dir: app_path
|
||||
source "https://gem.repo4"
|
||||
gem "mygem", "1.0"
|
||||
G
|
||||
end
|
||||
end
|
||||
|
||||
context "after installing with --standalone" do
|
||||
before do
|
||||
install_gemfile <<-G
|
||||
|
Loading…
x
Reference in New Issue
Block a user