Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remove special Sexp nodes from HAML processor #149

Merged
merged 3 commits into from

2 participants

@presidentbeef

Brakeman was generating invalid call Sexps with :_hamlout as the target for _hamlout.options and hamlout.buffer. However, these special Sexps were not really be handled in Brakeman anywhere, and there was no real reason to make special Sexps for them.

Brakeman was also creating Sexps with the :tag type, which was also not handled anywhere. If one of those nodes had made it to the OutputProcessor, it would certainly have caused problems.

It's possible some of this code was specific to older versions of HAML. This is old code that clearly expected use in the future that was never needed.

added some commits
@presidentbeef No special Sexps for options/buffer calls in HAML
Brakeman was generating invalid call Sexps with `:_hamlout`
as the target for `_hamlout.options` and `hamlout.buffer`.
However, these special Sexps were not really be handled in Brakeman
anywhere, and there was no real reason to make special Sexps for them.
0750e9f
@presidentbeef Remove unsupported :tag node type
Surprised this never caused any errors
ef8ea3f
@presidentbeef Remove special cased OutputProcessor#process_call
There should never be the case where the target of a :call Sexp is a
symbol, it should always be either `nil` or a Sexp. Brakeman should not
be building invalid Sexps.
c0cedbd
@oreoshake

take your word for it :thumbsup:

@presidentbeef presidentbeef merged commit 59aaaab into master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 19, 2012
  1. No special Sexps for options/buffer calls in HAML

    authored
    Brakeman was generating invalid call Sexps with `:_hamlout`
    as the target for `_hamlout.options` and `hamlout.buffer`.
    However, these special Sexps were not really be handled in Brakeman
    anywhere, and there was no real reason to make special Sexps for them.
  2. Remove unsupported :tag node type

    authored
    Surprised this never caused any errors
Commits on Sep 20, 2012
  1. Remove special cased OutputProcessor#process_call

    authored
    There should never be the case where the target of a :call Sexp is a
    symbol, it should always be either `nil` or a Sexp. Brakeman should not
    be building invalid Sexps.
This page is out of date. Refresh to see the latest.
View
11 lib/brakeman/processors/haml_template_processor.rb
@@ -29,16 +29,15 @@ def process_call exp
method = exp.method
- if (call? target and target.method == :_hamlout) or target == :_hamlout
+ if (call? target and target.method == :_hamlout)
res = case method
when :adjust_tabs, :rstrip!, :attributes #Check attributes, maybe?
ignore
- when :options
- Sexp.new :call, :_hamlout, :options, exp.arglist
- when :buffer
- Sexp.new :call, :_hamlout, :buffer, exp.arglist
+ when :options, :buffer
+ exp
when :open_tag
- Sexp.new(:tag, process(exp.arglist))
+ process(exp.arglist)
+ exp
else
arg = exp.first_arg
View
30 lib/brakeman/processors/output_processor.rb
@@ -23,36 +23,6 @@ def process exp
end
end
- def process_call exp
- if exp[0].is_a? Symbol
- target = exp[0]
-
- method = exp[1]
-
- args = process exp[2]
-
- out = nil
-
- if method == :[]
- if target
- out = "#{target}[#{args}]"
- else
- raise Exception.new("Not sure what to do with access and no target: #{exp}")
- end
- else
- if target
- out = "#{target}.#{method}(#{args})"
- else
- out = "#{method}(#{args})"
- end
- end
- exp.clear
- out
- else
- super exp
- end
- end
-
def process_lvar exp
out = "(local #{exp[0]})"
exp.clear
Something went wrong with that request. Please try again.