reports/html.rb in arachni-0.2.3 vs reports/html.rb in arachni-0.2.4

- old
+ new

@@ -9,10 +9,11 @@ =end require 'erb' require 'base64' require 'cgi' +require 'iconv' module Arachni require Options.instance.dir['lib'] + 'crypto/rsa_aes_cbc' @@ -22,11 +23,11 @@ # Creates an HTML report of the audit. # # @author: Tasos "Zapotek" Laskos # <tasos.laskos@gmail.com> # <zapotek@segfault.gr> -# @version: 0.2.1 +# @version: 0.2.2 # class HTML < Arachni::Report::Base REPORT_FP_URL = "https://arachni.segfault.gr/false_positive" @@ -85,18 +86,18 @@ def js_multiline( str ) "\"" + str.gsub( "\n", '\n' ) + "\""; end + def normalize( str ) + ic = ::Iconv.new( 'UTF-8//IGNORE', 'UTF-8' ) + ic.iconv( str + ' ' )[0..-2] + end + def escapeHTML( str ) # carefully escapes HTML and converts to UTF-8 # while removing invalid character sequences - begin - return CGI.escapeHTML( str ) - rescue - ic = Iconv.new( 'UTF-8//IGNORE', 'UTF-8' ) - return CGI.escapeHTML( ic.iconv( str + ' ' )[0..-2] ) - end + return CGI.escapeHTML( normalize( str ) ) end def self.prep_description( str ) placeholder = '--' + rand( 1000 ).to_s + '--' cstr = str.gsub( /^\s*$/xm, placeholder )