Sha256: decb20787e110e6100a30618a2c6aa1ba28d8d16ed71e94e7cd97a38b58a1370

Contents?: true

Size: 1.41 KB

Versions: 33

Compression:

Stored size: 1.41 KB

Contents

Brakeman.load_brakeman_dependency 'erubis'

#This is from Rails 3 version of the Erubis handler
class Brakeman::Rails3Erubis < ::Erubis::Eruby

  def add_preamble(src)
    # src << "_buf = ActionView::SafeBuffer.new;\n"
  end

  #This is different from Rails 3 - fixes some line number issues
  def add_text(src, text)
    if text == "\n"
      src << "\n"
    elsif text.include? "\n"
      lines = text.split("\n")
      if text.match(/\n\z/)
        lines.each do |line|
          src << "@output_buffer << ('" << escape_text(line) << "'.html_safe!);\n"
        end
      else
        lines[0..-2].each do |line|
          src << "@output_buffer << ('" << escape_text(line) << "'.html_safe!);\n"
        end

        src << "@output_buffer << ('" << escape_text(lines.last) << "'.html_safe!);"
      end
    else
      src << "@output_buffer << ('" << escape_text(text) << "'.html_safe!);"
    end
  end

  BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/

  def add_expr_literal(src, code)
    if code =~ BLOCK_EXPR
      src << '@output_buffer.append= ' << code
    else
      src << '@output_buffer.append= (' << code << ');'
    end
  end

  def add_expr_escaped(src, code)
    if code =~ BLOCK_EXPR
      src << "@output_buffer.safe_append= " << code
    else
      src << "@output_buffer.safe_append= (" << code << ");"
    end
  end

  #Add code to output buffer.
  def add_postamble(src)
    # src << '_buf.to_s'
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
brakeman-3.3.0 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.3.0 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.2.1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.2.1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.2.0 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.2.0 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.2.0.pre1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.2.0.pre1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.5.pre1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.5 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.5 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.4 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.4 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.3 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.3 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.2 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.2 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-min-3.1.1 lib/brakeman/parsers/rails3_erubis.rb
brakeman-3.1.0 lib/brakeman/parsers/rails3_erubis.rb