Method: Rex::Text.badchar_index

Defined in:
lib/rex/text.rb

.badchar_index(data, badchars = '') ⇒ Fixnum?

Return the index of the first badchar in data, otherwise return nil if there wasn’t any badchar occurences.

Parameters:

  • data (String)

    The string to check for bad characters

  • badchars (String) (defaults to: '')

    A list of characters considered to be bad

Returns:

  • (Fixnum)

    Index of the first bad character if any exist in data

  • (nil)

    If data contains no bad characters



1510
1511
1512
1513
1514
1515
1516
# File 'lib/rex/text.rb', line 1510

def self.badchar_index(data, badchars = '')
  badchars.unpack("C*").each { |badchar|
    pos = data.index(badchar.chr)
    return pos if pos
  }
  return nil
end