From 2ea1950510003dbce5a761a712039ed69fa499f2 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 16 Sep 2024 14:40:19 -0400 Subject: [ruby/prism] Do not leak explicit encoding Fixes [Bug #20744] https://github.com/ruby/prism/commit/f1b8b1b2a2 --- lib/prism/translation/ruby_parser.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index 9cd39075ec..4ccff0b600 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -1428,7 +1428,13 @@ module Prism # "foo" # ^^^^^ def visit_string_node(node) - s(node, :str, node.unescaped) + unescaped = node.unescaped + + if node.forced_binary_encoding? + unescaped.force_encoding(Encoding::BINARY) + end + + s(node, :str, unescaped) end # super(foo) -- cgit v1.2.3