Skip to content
This repository

Remove special Sexp nodes from HAML processor #149

Merged
merged 3 commits into from over 1 year ago

2 participants

Justin Neil Matatall
Justin

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.

Justin 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
Justin Remove unsupported :tag node type
Surprised this never caused any errors
ef8ea3f
Justin 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
Neil Matatall
Collaborator

take your word for it :thumbsup:

Justin presidentbeef merged commit 59aaaab into from September 21, 2012
Justin presidentbeef closed this September 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

Sep 19, 2012
Justin 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
Justin Remove unsupported :tag node type
Surprised this never caused any errors
ef8ea3f
Justin 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
This page is out of date. Refresh to see the latest.
11  lib/brakeman/processors/haml_template_processor.rb
@@ -29,16 +29,15 @@ def process_call exp
29 29
 
30 30
     method = exp.method
31 31
 
32  
-    if (call? target and target.method == :_hamlout) or target == :_hamlout
  32
+    if (call? target and target.method == :_hamlout)
33 33
       res = case method
34 34
             when :adjust_tabs, :rstrip!, :attributes #Check attributes, maybe?
35 35
               ignore
36  
-            when :options
37  
-              Sexp.new :call, :_hamlout, :options, exp.arglist
38  
-            when :buffer
39  
-              Sexp.new :call, :_hamlout, :buffer, exp.arglist
  36
+            when :options, :buffer
  37
+              exp
40 38
             when :open_tag
41  
-              Sexp.new(:tag, process(exp.arglist))
  39
+              process(exp.arglist)
  40
+              exp
42 41
             else
43 42
               arg = exp.first_arg
44 43
 
30  lib/brakeman/processors/output_processor.rb
@@ -23,36 +23,6 @@ def process exp
23 23
     end
24 24
   end
25 25
 
26  
-  def process_call exp
27  
-    if exp[0].is_a? Symbol
28  
-      target = exp[0]
29  
-
30  
-      method = exp[1]
31  
-
32  
-      args = process exp[2]
33  
-
34  
-      out = nil
35  
-
36  
-      if method == :[]
37  
-        if target
38  
-          out = "#{target}[#{args}]"
39  
-        else
40  
-          raise Exception.new("Not sure what to do with access and no target: #{exp}")
41  
-        end
42  
-      else
43  
-        if target
44  
-          out = "#{target}.#{method}(#{args})"
45  
-        else
46  
-          out = "#{method}(#{args})"
47  
-        end
48  
-      end
49  
-      exp.clear
50  
-      out
51  
-    else
52  
-      super exp
53  
-    end
54  
-  end
55  
-
56 26
   def process_lvar exp
57 27
     out = "(local #{exp[0]})"
58 28
     exp.clear
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.