-
-
Save luislavena/19f244f71b3255776c7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment