summaryrefslogtreecommitdiff
path: root/test/rubygems/test_gem_remote_fetcher.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-12-13 16:53:50 +0100
committergit <svn-admin@ruby-lang.org>2021-12-15 19:46:44 +0900
commit9f87c0cc6dff70e8a1c4d204d1d45920d26f2e3a (patch)
tree137f13cb562f16c14374ceff86ad32dd2d7b13ea /test/rubygems/test_gem_remote_fetcher.rb
parentc2dbdf3067c334e22946fbda74181d3a94afbf97 (diff)
[rubygems/rubygems] Pass `:bimode` explicitly to `File.open`
The `File::BINARY` flag is apparently ignored due to a ruby bug, and thus writing can cause encoding issues. https://github.com/rubygems/rubygems/commit/db4efbebf2
Diffstat (limited to 'test/rubygems/test_gem_remote_fetcher.rb')
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb
index 5ce420b91a..3ce9be7c90 100644
--- a/test/rubygems/test_gem_remote_fetcher.rb
+++ b/test/rubygems/test_gem_remote_fetcher.rb
@@ -173,6 +173,21 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
assert_equal 'hello', File.read(path)
end
+ def test_cache_update_path_with_utf8_internal_encoding
+ with_internal_encoding('UTF-8') do
+ uri = URI 'http://example/file'
+ path = File.join @tempdir, 'file'
+ data = String.new("\xC8").force_encoding(Encoding::BINARY)
+
+ fetcher = util_fuck_with_fetcher data
+
+ written_data = fetcher.cache_update_path uri, path
+
+ assert_equal data, written_data
+ assert_equal data, File.binread(path)
+ end
+ end
+
def test_cache_update_path_no_update
uri = URI 'http://example/file'
path = File.join @tempdir, 'file'