File tree Expand file tree Collapse file tree 4 files changed +55
-5
lines changed Expand file tree Collapse file tree 4 files changed +55
-5
lines changed Original file line number Diff line number Diff line change @@ -433,4 +433,18 @@ def installed?
433433 end
434434 end
435435 end
436+
437+ unless Gem . rubygems_version >= Gem ::Version . new ( "3.5.23" )
438+ class Package ; end
439+ require "rubygems/package/tar_reader"
440+ require "rubygems/package/tar_reader/entry"
441+
442+ module FixFullNameEncoding
443+ def full_name
444+ super . force_encoding ( Encoding ::UTF_8 )
445+ end
446+ end
447+
448+ Package ::TarReader ::Entry . prepend ( FixFullNameEncoding )
449+ end
436450end
Original file line number Diff line number Diff line change @@ -1218,6 +1218,35 @@ def run
12181218 end
12191219 end
12201220
1221+ describe "when configured path is UTF-8 and a file inside a gem package too" do
1222+ let ( :app_path ) do
1223+ path = tmp ( "♥" )
1224+ FileUtils . mkdir_p ( path )
1225+ path
1226+ end
1227+
1228+ let ( :path ) do
1229+ root . join ( "vendor/bundle" )
1230+ end
1231+
1232+ before do
1233+ build_repo4 do
1234+ build_gem "mygem" do |s |
1235+ s . write "spec/fixtures/_posts/2016-04-01-错误.html"
1236+ end
1237+ end
1238+ end
1239+
1240+ it "works" do
1241+ bundle "config path #{ app_path } /vendor/bundle" , dir : app_path
1242+
1243+ install_gemfile app_path . join ( "Gemfile" ) , <<~G , dir : app_path
1244+ source "https://gem.repo4"
1245+ gem "mygem", "1.0"
1246+ G
1247+ end
1248+ end
1249+
12211250 context "after installing with --standalone" do
12221251 before do
12231252 install_gemfile <<-G
Original file line number Diff line number Diff line change @@ -228,6 +228,17 @@ def update_checksum
228228 @checksum = oct calculate_checksum ( header ) , 6
229229 end
230230
231+ ##
232+ # Header's full name, including prefix
233+
234+ def full_name
235+ if prefix != ""
236+ File . join prefix , name
237+ else
238+ name
239+ end
240+ end
241+
231242 private
232243
233244 def calculate_checksum ( header )
Original file line number Diff line number Diff line change @@ -87,11 +87,7 @@ def eof?
8787 # Full name of the tar entry
8888
8989 def full_name
90- if @header . prefix != ""
91- File . join @header . prefix , @header . name
92- else
93- @header . name
94- end
90+ @header . full_name . force_encoding ( Encoding ::UTF_8 )
9591 rescue ArgumentError => e
9692 raise unless e . message == "string contains null byte"
9793 raise Gem ::Package ::TarInvalidError ,
You can’t perform that action at this time.
0 commit comments