summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCharles Oliver Nutter <headius@headius.com>2017-09-07 16:25:54 -0500
committerGitHub <noreply@github.com>2017-09-07 16:25:54 -0500
commitb572261900893df0352d3ad71c17dfa81ab17ccc (patch)
tree3bcf8b863240a2dfb2023242fe2a35d71ba4add2 /test
parent4039a811248de7b0b9ae9e4a97854f00ba985255 (diff)
parent2bbb245edaf80179f4673bf4bf75978a10654c64 (diff)
downloadpsych-b572261900893df0352d3ad71c17dfa81ab17ccc.zip
Merge pull request #328 from enebo/desensitize_io_encoding_on_load
Parse.load with an IO/File which has a non-YAML allowed encoding will…
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_encoding.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/psych/test_encoding.rb b/test/psych/test_encoding.rb
index a4f9f03..01ebe25 100644
--- a/test/psych/test_encoding.rb
+++ b/test/psych/test_encoding.rb
@@ -106,6 +106,18 @@ module Psych
}
end
+ def test_io_utf8_read_as_binary
+ Tempfile.create(['utf8', 'yml']) {|t|
+ t.binmode
+ t.write '--- こんにちは!'.encode('UTF-8')
+ t.close
+
+ File.open(t.path, 'rb', :encoding => 'ascii-8bit') do |f|
+ assert_equal "こんにちは!", Psych.load(f)
+ end
+ }
+ end
+
def test_emit_alias
@emitter.start_stream Psych::Parser::UTF8
@emitter.start_document [], [], true