secret
Created

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index c40a86a..88c491d 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -900,7 +900,7 @@ class Gem::Specification
return unless File.file?(file)
code = if defined? Encoding
- File.read file, :encoding => "UTF-8"
+ File.read file, :mode => 'r:UTF-8:-'
else
File.read file
end
diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb
index f1def67..d5f69f3 100644
--- a/test/rubygems/test_gem_specification.rb
+++ b/test/rubygems/test_gem_specification.rb
@@ -308,6 +308,25 @@ bindir:
assert_equal @a2, spec
end
+ if defined?(Encoding)
+ def test_self_load_utf8_with_ascii_encoding
+ int_enc = Encoding.default_internal
+ Encoding.default_internal = 'US-ASCII'
+
+ spec2 = @a2.dup
+ spec2.authors = ["\u5678"]
+ full_path = spec2.spec_file
+ write_file full_path do |io|
+ io.write spec2.to_ruby_for_cache
+ end
+ spec2.files.clear
+
+ assert_equal spec2, spec
+ ensure
+ Encoding.default_internal = int_enc
+ end
+ end
+
def test_self_load_legacy_ruby
spec = Gem::Deprecate.skip_during do
eval LEGACY_RUBY_SPEC

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.