Skip to content

Commit

Permalink
Encoding::Base16.decode should actually return an ASCII-8bit String.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jun 9, 2023
1 parent f3cc768 commit c0f29f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ronin/support/encoding/base16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def self.encode(data)
# # => "hello"
#
def self.decode(data)
decoded = String.new(encoding: Encoding::UTF_8)
decoded = String.new(encoding: Encoding::ASCII_8BIT)

data.scan(/../).each do |hex_char|
decoded << hex_char.to_i(16).chr
Expand Down
4 changes: 2 additions & 2 deletions spec/encoding/base16_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
expect(subject.decode(data)).to eq("hello\x4e")
end

it "must set the String encoding to Encoding::UTF_8" do
expect(subject.decode(data).encoding).to be(Encoding::UTF_8)
it "must set the String encoding to Encoding::ASCII_8BIT" do
expect(subject.decode(data).encoding).to be(Encoding::ASCII_8BIT)
end
end
end

0 comments on commit c0f29f9

Please sign in to comment.