1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

String stuffs

git-svn-id: file:///home/svn/incoming/trunk@2606 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
Spoon M 2005-06-09 16:47:49 +00:00
parent 32e2e0503e
commit a7dc32cb50
2 changed files with 38 additions and 0 deletions

19
lib/rex/string_utils.rb Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/ruby
module Rex
module StringUtils
#
# Return the index of the first badchar in data, otherwise return
# nil if there wasn't any badchar occurences.
#
def self.badchar_index(data, badchars)
badchars.each_byte { |badchar|
pos = data.index(badchar)
return pos if pos
}
return nil
end
end end

View File

@ -0,0 +1,19 @@
#!/usr/bin/ruby
$:.unshift(File.join(File.dirname(__FILE__), '..'))
require 'test/unit'
require 'Rex/StringUtils'
class Rex::StringUtils::UnitTest < ::Test::Unit::TestCase
Klass = Rex::StringUtils
def klass
self.class::Klass
end
def test_badchar_index
assert_equal(nil, klass.badchar_index('abcdef', 'gzk'))
assert_equal(2, klass.badchar_index('123avd', 'ly3'))
end
end