Class: Watobo::Gui::TaglessViewer
- Inherits:
-
SimpleTextView
- Object
- FXVerticalFrame
- SimpleTextView
- Watobo::Gui::TaglessViewer
- Defined in:
- lib/watobo/gui/tagless_viewer.rb
Constant Summary
Constants included from Constants
Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::AUTH_TYPE_UNKNOWN, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED
Instance Attribute Summary
Attributes inherited from SimpleTextView
Instance Method Summary collapse
-
#initialize(owner, opts) ⇒ TaglessViewer
constructor
A new instance of TaglessViewer.
- #normalizeText(text) ⇒ Object
Methods inherited from SimpleTextView
#clear, #clearEvents, #editable=, #editable?, #filter, #highlight, #makeMatchVisible, #numMatches, #rawRequest, #resetMatches, #setFont, #setText, #subscribe, #textStyle, #textStyle=
Methods included from Utils
#addDecoder, #addEncoder, #addStringInfo, #cleanupHTTP, load_plugins, #removeTags, #replace_text
Constructor Details
#initialize(owner, opts) ⇒ TaglessViewer
Returns a new instance of TaglessViewer.
37 38 39 |
# File 'lib/watobo/gui/tagless_viewer.rb', line 37 def initialize(owner, opts) super(owner, opts) end |
Instance Method Details
#normalizeText(text) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/watobo/gui/tagless_viewer.rb', line 6 def normalizeText(text) return '' if text.nil? raw_text = text if text.is_a? Array then raw_text = text.join end #remove headers body_start = raw_text.index("\r\n\r\n") body_start = body_start.nil? ? 0 : body_start #puts "* start normalizing at pos #{body_start}" normalized = raw_text[body_start..-1] # UTF-8 Clean-Up normalized = normalized.unpack("C*").pack("C*") # remove all inbetween tags normalized.gsub!(/<.*?>/m, '') # remove non printable characters, except LF (\x0a) r = Regexp.new '[\x00-\x09\x0b-\x1f\x7f-\xff]+', nil, 'n' normalized.gsub!( r,'') # remove empty lines normalized.gsub!(/((\x20+)?\x0a(\x20+)?)+/,"\n") # decode html entities for better readability normalized = CGI.unescapeHTML(normalized) # additionally unescape which is not handled by CGI :( normalized.gsub!(/(#{Regexp.quote(' ')})+/," ") # finally strip it normalized.strip end |