Skip to content

Commit

Permalink
Treat all input as strings, avoids some sloppy caller code that wasn'…
Browse files Browse the repository at this point in the history
…t as strict before

git-svn-id: file:///home/svn/framework3/trunk@13995 4d416f70-5f16-0410-b530-b9f4589650da
  • Loading branch information
HD Moore committed Oct 18, 2011
1 parent 9732279 commit 3cfa3c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rex/text.rb
Expand Up @@ -1131,15 +1131,15 @@ def self.pack_int64le(val)
# Punycode would have been more "standard", but it requires valid Unicode chars
#
def self.unicode_filter_encode(str)
if (str.unpack("C*") & ( LowAscii + HighAscii + "\x7f" ).unpack("C*")).length > 0
if (str.to_s.unpack("C*") & ( LowAscii + HighAscii + "\x7f" ).unpack("C*")).length > 0
str = "$U$" + str.unpack("C*").select{|c| c < 0x7f and c > 0x1f and c != 0x2d}.pack("C*") + "-0x" + str.unpack("H*")[0]
else
str
end
end

def self.unicode_filter_decode(str)
str.gsub( /\$U\$([\x20-\x2c\x2e-\x7E]*)\-0x([A-Fa-f0-9]+)/ ){|m| [$2].pack("H*") }
str.to_s.gsub( /\$U\$([\x20-\x2c\x2e-\x7E]*)\-0x([A-Fa-f0-9]+)/ ){|m| [$2].pack("H*") }
end

protected
Expand Down

0 comments on commit 3cfa3c2

Please sign in to comment.