summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-09-16 14:40:19 -0400
committergit <svn-admin@ruby-lang.org>2024-09-16 18:57:54 +0000
commit2ea1950510003dbce5a761a712039ed69fa499f2 (patch)
tree1a5cfc65a27c437422a7fd0b17b83354b69274f6 /lib
parent1e53e46275e2f49a711ff90adddc804d11a347b1 (diff)
[ruby/prism] Do not leak explicit encoding
Fixes [Bug #20744] https://github.com/ruby/prism/commit/f1b8b1b2a2
Diffstat (limited to 'lib')
-rw-r--r--lib/prism/translation/ruby_parser.rb8
1 files changed, 7 insertions, 1 deletions
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)