brakeman 7.1.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -0
- data/README.md +1 -1
- data/bundle/load.rb +2 -2
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
- data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/asciidoc.rb +12 -5
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/babel.rb +5 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/builder.rb +4 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/coffee.rb +14 -4
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/commonmarker.rb +41 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/csv.rb +63 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/erb.rb +130 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/erubi.rb +41 -8
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/etanni.rb +7 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/haml.rb +67 -1
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/kramdown.rb +59 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/liquid.rb +93 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/livescript.rb +11 -4
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/mapping.rb +8 -8
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/markaby.rb +11 -2
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/nokogiri.rb +13 -2
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/pandoc.rb +81 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/pipeline.rb +6 -1
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/plain.rb +5 -1
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/prawn.rb +17 -6
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/radius.rb +96 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdiscount.rb +82 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdoc.rb +33 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcarpet.rb +73 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcloth.rb +40 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rst-pandoc.rb +33 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/sass.rb +16 -3
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/slim.rb +18 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/string.rb +10 -2
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/template.rb +5 -5
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/typescript.rb +5 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/yajl.rb +91 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt.rb +1 -2
- data/lib/brakeman/app_tree.rb +7 -2
- data/lib/brakeman/checks/check_model_attributes.rb +1 -1
- data/lib/brakeman/checks/check_render.rb +1 -27
- data/lib/brakeman/checks/check_render_rce.rb +43 -0
- data/lib/brakeman/checks/check_session_settings.rb +1 -1
- data/lib/brakeman/checks.rb +31 -25
- data/lib/brakeman/commandline.rb +6 -1
- data/lib/brakeman/file_parser.rb +3 -2
- data/lib/brakeman/logger.rb +264 -0
- data/lib/brakeman/options.rb +0 -9
- data/lib/brakeman/parsers/rails_erubi.rb +82 -0
- data/lib/brakeman/parsers/template_parser.rb +7 -15
- data/lib/brakeman/processor.rb +2 -2
- data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
- data/lib/brakeman/processors/controller_processor.rb +3 -3
- data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
- data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
- data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
- data/lib/brakeman/processors/lib/render_helper.rb +1 -1
- data/lib/brakeman/processors/lib/render_path.rb +1 -1
- data/lib/brakeman/processors/model_processor.rb +1 -1
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/scanner.rb +25 -49
- data/lib/brakeman/tracker/collection.rb +12 -2
- data/lib/brakeman/tracker/config.rb +17 -13
- data/lib/brakeman/tracker/constants.rb +17 -2
- data/lib/brakeman/tracker/controller.rb +1 -1
- data/lib/brakeman/tracker.rb +7 -15
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +89 -49
- metadata +51 -80
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
- data/lib/brakeman/parsers/erubis_patch.rb +0 -11
- data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
- data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
- data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/COPYING +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_emacs_org.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_handlebars.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_jbuilder.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_org.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/cli.rb +0 -0
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
## $Release: 2.7.0 $
|
|
3
|
-
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
require 'erubis/util'
|
|
7
|
-
|
|
8
|
-
module Erubis
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
##
|
|
12
|
-
## convert
|
|
13
|
-
##
|
|
14
|
-
module Converter
|
|
15
|
-
|
|
16
|
-
attr_accessor :preamble, :postamble, :escape
|
|
17
|
-
|
|
18
|
-
def self.supported_properties # :nodoc:
|
|
19
|
-
return [
|
|
20
|
-
[:preamble, nil, "preamble (no preamble when false)"],
|
|
21
|
-
[:postamble, nil, "postamble (no postamble when false)"],
|
|
22
|
-
[:escape, nil, "escape expression or not in default"],
|
|
23
|
-
]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def init_converter(properties={})
|
|
27
|
-
@preamble = properties[:preamble]
|
|
28
|
-
@postamble = properties[:postamble]
|
|
29
|
-
@escape = properties[:escape]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
## convert input string into target language
|
|
33
|
-
def convert(input)
|
|
34
|
-
codebuf = "" # or []
|
|
35
|
-
@preamble.nil? ? add_preamble(codebuf) : (@preamble && (codebuf << @preamble))
|
|
36
|
-
convert_input(codebuf, input)
|
|
37
|
-
@postamble.nil? ? add_postamble(codebuf) : (@postamble && (codebuf << @postamble))
|
|
38
|
-
@_proc = nil # clear cached proc object
|
|
39
|
-
return codebuf # or codebuf.join()
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
protected
|
|
43
|
-
|
|
44
|
-
##
|
|
45
|
-
## detect spaces at beginning of line
|
|
46
|
-
##
|
|
47
|
-
def detect_spaces_at_bol(text, is_bol)
|
|
48
|
-
lspace = nil
|
|
49
|
-
if text.empty?
|
|
50
|
-
lspace = "" if is_bol
|
|
51
|
-
elsif text[-1] == ?\n
|
|
52
|
-
lspace = ""
|
|
53
|
-
else
|
|
54
|
-
rindex = text.rindex(?\n)
|
|
55
|
-
if rindex
|
|
56
|
-
s = text[rindex+1..-1]
|
|
57
|
-
if s =~ /\A[ \t]*\z/
|
|
58
|
-
lspace = s
|
|
59
|
-
#text = text[0..rindex]
|
|
60
|
-
text[rindex+1..-1] = ''
|
|
61
|
-
end
|
|
62
|
-
else
|
|
63
|
-
if is_bol && text =~ /\A[ \t]*\z/
|
|
64
|
-
#lspace = text
|
|
65
|
-
#text = nil
|
|
66
|
-
lspace = text.dup
|
|
67
|
-
text[0..-1] = ''
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
return lspace
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
##
|
|
75
|
-
## (abstract) convert input to code
|
|
76
|
-
##
|
|
77
|
-
def convert_input(codebuf, input)
|
|
78
|
-
not_implemented
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
module Basic
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
##
|
|
89
|
-
## basic converter which supports '<% ... %>' notation.
|
|
90
|
-
##
|
|
91
|
-
module Basic::Converter
|
|
92
|
-
include Erubis::Converter
|
|
93
|
-
|
|
94
|
-
def self.supported_properties # :nodoc:
|
|
95
|
-
return [
|
|
96
|
-
[:pattern, '<% %>', "embed pattern"],
|
|
97
|
-
[:trim, true, "trim spaces around <% ... %>"],
|
|
98
|
-
]
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
attr_accessor :pattern, :trim
|
|
102
|
-
|
|
103
|
-
def init_converter(properties={})
|
|
104
|
-
super(properties)
|
|
105
|
-
@pattern = properties[:pattern]
|
|
106
|
-
@trim = properties[:trim] != false
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
protected
|
|
110
|
-
|
|
111
|
-
## return regexp of pattern to parse eRuby script
|
|
112
|
-
def pattern_regexp(pattern)
|
|
113
|
-
@prefix, @postfix = pattern.split() # '<% %>' => '<%', '%>'
|
|
114
|
-
#return /(.*?)(^[ \t]*)?#{@prefix}(=+|\#)?(.*?)-?#{@postfix}([ \t]*\r?\n)?/m
|
|
115
|
-
#return /(^[ \t]*)?#{@prefix}(=+|\#)?(.*?)-?#{@postfix}([ \t]*\r?\n)?/m
|
|
116
|
-
return /#{@prefix}(=+|-|\#|%)?(.*?)([-=])?#{@postfix}([ \t]*\r?\n)?/m
|
|
117
|
-
end
|
|
118
|
-
module_function :pattern_regexp
|
|
119
|
-
|
|
120
|
-
#DEFAULT_REGEXP = /(.*?)(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
121
|
-
#DEFAULT_REGEXP = /(^[ \t]*)?<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
122
|
-
#DEFAULT_REGEXP = /<%(=+|\#)?(.*?)-?%>([ \t]*\r?\n)?/m
|
|
123
|
-
DEFAULT_REGEXP = pattern_regexp('<% %>')
|
|
124
|
-
|
|
125
|
-
public
|
|
126
|
-
|
|
127
|
-
def convert_input(src, input)
|
|
128
|
-
pat = @pattern
|
|
129
|
-
regexp = pat.nil? || pat == '<% %>' ? DEFAULT_REGEXP : pattern_regexp(pat)
|
|
130
|
-
pos = 0
|
|
131
|
-
is_bol = true # is beginning of line
|
|
132
|
-
input.scan(regexp) do |indicator, code, tailch, rspace|
|
|
133
|
-
match = Regexp.last_match()
|
|
134
|
-
len = match.begin(0) - pos
|
|
135
|
-
text = input[pos, len]
|
|
136
|
-
pos = match.end(0)
|
|
137
|
-
ch = indicator ? indicator[0] : nil
|
|
138
|
-
lspace = ch == ?= ? nil : detect_spaces_at_bol(text, is_bol)
|
|
139
|
-
is_bol = rspace ? true : false
|
|
140
|
-
add_text(src, text) if text && !text.empty?
|
|
141
|
-
## * when '<%= %>', do nothing
|
|
142
|
-
## * when '<% %>' or '<%# %>', delete spaces iff only spaces are around '<% %>'
|
|
143
|
-
if ch == ?= # <%= %>
|
|
144
|
-
rspace = nil if tailch && !tailch.empty?
|
|
145
|
-
add_text(src, lspace) if lspace
|
|
146
|
-
add_expr(src, code, indicator)
|
|
147
|
-
add_text(src, rspace) if rspace
|
|
148
|
-
elsif ch == ?\# # <%# %>
|
|
149
|
-
n = code.count("\n") + (rspace ? 1 : 0)
|
|
150
|
-
if @trim && lspace && rspace
|
|
151
|
-
add_stmt(src, "\n" * n)
|
|
152
|
-
else
|
|
153
|
-
add_text(src, lspace) if lspace
|
|
154
|
-
add_stmt(src, "\n" * n)
|
|
155
|
-
add_text(src, rspace) if rspace
|
|
156
|
-
end
|
|
157
|
-
elsif ch == ?% # <%% %>
|
|
158
|
-
s = "#{lspace}#{@prefix||='<%'}#{code}#{tailch}#{@postfix||='%>'}#{rspace}"
|
|
159
|
-
add_text(src, s)
|
|
160
|
-
else # <% %>
|
|
161
|
-
if @trim && lspace && rspace
|
|
162
|
-
add_stmt(src, "#{lspace}#{code}#{rspace}")
|
|
163
|
-
else
|
|
164
|
-
add_text(src, lspace) if lspace
|
|
165
|
-
add_stmt(src, code)
|
|
166
|
-
add_text(src, rspace) if rspace
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
#rest = $' || input # ruby1.8
|
|
171
|
-
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
|
172
|
-
add_text(src, rest)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
## add expression code to src
|
|
176
|
-
def add_expr(src, code, indicator)
|
|
177
|
-
case indicator
|
|
178
|
-
when '='
|
|
179
|
-
@escape ? add_expr_escaped(src, code) : add_expr_literal(src, code)
|
|
180
|
-
when '=='
|
|
181
|
-
@escape ? add_expr_literal(src, code) : add_expr_escaped(src, code)
|
|
182
|
-
when '==='
|
|
183
|
-
add_expr_debug(src, code)
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
module PI
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
##
|
|
194
|
-
## Processing Instructions (PI) converter for XML.
|
|
195
|
-
## this class converts '<?rb ... ?>' and '${...}' notation.
|
|
196
|
-
##
|
|
197
|
-
module PI::Converter
|
|
198
|
-
include Erubis::Converter
|
|
199
|
-
|
|
200
|
-
def self.desc # :nodoc:
|
|
201
|
-
"use processing instructions (PI) instead of '<% %>'"
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def self.supported_properties # :nodoc:
|
|
205
|
-
return [
|
|
206
|
-
[:trim, true, "trim spaces around <% ... %>"],
|
|
207
|
-
[:pi, 'rb', "PI (Processing Instrunctions) name"],
|
|
208
|
-
[:embchar, '@', "char for embedded expression pattern('@{...}@')"],
|
|
209
|
-
[:pattern, '<% %>', "embed pattern"],
|
|
210
|
-
]
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
attr_accessor :pi, :prefix
|
|
214
|
-
|
|
215
|
-
def init_converter(properties={})
|
|
216
|
-
super(properties)
|
|
217
|
-
@trim = properties.fetch(:trim, true)
|
|
218
|
-
@pi = properties[:pi] if properties[:pi]
|
|
219
|
-
@embchar = properties[:embchar] || '@'
|
|
220
|
-
@pattern = properties[:pattern]
|
|
221
|
-
@pattern = '<% %>' if @pattern.nil? #|| @pattern == true
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def convert(input)
|
|
225
|
-
code = super(input)
|
|
226
|
-
return @header || @footer ? "#{@header}#{code}#{@footer}" : code
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
protected
|
|
230
|
-
|
|
231
|
-
def convert_input(codebuf, input)
|
|
232
|
-
unless @regexp
|
|
233
|
-
@pi ||= 'e'
|
|
234
|
-
ch = Regexp.escape(@embchar)
|
|
235
|
-
if @pattern
|
|
236
|
-
left, right = @pattern.split(' ')
|
|
237
|
-
@regexp = /<\?#{@pi}(?:-(\w+))?(\s.*?)\?>([ \t]*\r?\n)?|#{ch}(!*)?\{(.*?)\}#{ch}|#{left}(=+)(.*?)#{right}/m
|
|
238
|
-
else
|
|
239
|
-
@regexp = /<\?#{@pi}(?:-(\w+))?(\s.*?)\?>([ \t]*\r?\n)?|#{ch}(!*)?\{(.*?)\}#{ch}/m
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
#
|
|
243
|
-
is_bol = true
|
|
244
|
-
pos = 0
|
|
245
|
-
input.scan(@regexp) do |pi_arg, stmt, rspace,
|
|
246
|
-
indicator1, expr1, indicator2, expr2|
|
|
247
|
-
match = Regexp.last_match
|
|
248
|
-
len = match.begin(0) - pos
|
|
249
|
-
text = input[pos, len]
|
|
250
|
-
pos = match.end(0)
|
|
251
|
-
lspace = stmt ? detect_spaces_at_bol(text, is_bol) : nil
|
|
252
|
-
is_bol = stmt && rspace ? true : false
|
|
253
|
-
add_text(codebuf, text) # unless text.empty?
|
|
254
|
-
#
|
|
255
|
-
if stmt
|
|
256
|
-
if @trim && lspace && rspace
|
|
257
|
-
add_pi_stmt(codebuf, "#{lspace}#{stmt}#{rspace}", pi_arg)
|
|
258
|
-
else
|
|
259
|
-
add_text(codebuf, lspace) if lspace
|
|
260
|
-
add_pi_stmt(codebuf, stmt, pi_arg)
|
|
261
|
-
add_text(codebuf, rspace) if rspace
|
|
262
|
-
end
|
|
263
|
-
else
|
|
264
|
-
add_pi_expr(codebuf, expr1 || expr2, indicator1 || indicator2)
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
#rest = $' || input # ruby1.8
|
|
268
|
-
rest = pos == 0 ? input : input[pos..-1] # ruby1.9
|
|
269
|
-
add_text(codebuf, rest)
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
#--
|
|
273
|
-
#def convert_input(codebuf, input)
|
|
274
|
-
# parse_stmts(codebuf, input)
|
|
275
|
-
# #parse_stmts2(codebuf, input)
|
|
276
|
-
#end
|
|
277
|
-
#
|
|
278
|
-
#def parse_stmts(codebuf, input)
|
|
279
|
-
# #regexp = pattern_regexp(@pattern)
|
|
280
|
-
# @pi ||= 'e'
|
|
281
|
-
# @stmt_pattern ||= /<\?#{@pi}(?:-(\w+))?(\s.*?)\?>([ \t]*\r?\n)?/m
|
|
282
|
-
# is_bol = true
|
|
283
|
-
# pos = 0
|
|
284
|
-
# input.scan(@stmt_pattern) do |pi_arg, code, rspace|
|
|
285
|
-
# match = Regexp.last_match
|
|
286
|
-
# len = match.begin(0) - pos
|
|
287
|
-
# text = input[pos, len]
|
|
288
|
-
# pos = match.end(0)
|
|
289
|
-
# lspace = detect_spaces_at_bol(text, is_bol)
|
|
290
|
-
# is_bol = rspace ? true : false
|
|
291
|
-
# parse_exprs(codebuf, text) # unless text.empty?
|
|
292
|
-
# if @trim && lspace && rspace
|
|
293
|
-
# add_pi_stmt(codebuf, "#{lspace}#{code}#{rspace}", pi_arg)
|
|
294
|
-
# else
|
|
295
|
-
# add_text(codebuf, lspace)
|
|
296
|
-
# add_pi_stmt(codebuf, code, pi_arg)
|
|
297
|
-
# add_text(codebuf, rspace)
|
|
298
|
-
# end
|
|
299
|
-
# end
|
|
300
|
-
# rest = $' || input
|
|
301
|
-
# parse_exprs(codebuf, rest)
|
|
302
|
-
#end
|
|
303
|
-
#
|
|
304
|
-
#def parse_exprs(codebuf, input)
|
|
305
|
-
# unless @expr_pattern
|
|
306
|
-
# ch = Regexp.escape(@embchar)
|
|
307
|
-
# if @pattern
|
|
308
|
-
# left, right = @pattern.split(' ')
|
|
309
|
-
# @expr_pattern = /#{ch}(!*)?\{(.*?)\}#{ch}|#{left}(=+)(.*?)#{right}/
|
|
310
|
-
# else
|
|
311
|
-
# @expr_pattern = /#{ch}(!*)?\{(.*?)\}#{ch}/
|
|
312
|
-
# end
|
|
313
|
-
# end
|
|
314
|
-
# pos = 0
|
|
315
|
-
# input.scan(@expr_pattern) do |indicator1, code1, indicator2, code2|
|
|
316
|
-
# indicator = indicator1 || indicator2
|
|
317
|
-
# code = code1 || code2
|
|
318
|
-
# match = Regexp.last_match
|
|
319
|
-
# len = match.begin(0) - pos
|
|
320
|
-
# text = input[pos, len]
|
|
321
|
-
# pos = match.end(0)
|
|
322
|
-
# add_text(codebuf, text) # unless text.empty?
|
|
323
|
-
# add_pi_expr(codebuf, code, indicator)
|
|
324
|
-
# end
|
|
325
|
-
# rest = $' || input
|
|
326
|
-
# add_text(codebuf, rest)
|
|
327
|
-
#end
|
|
328
|
-
#++
|
|
329
|
-
|
|
330
|
-
def add_pi_stmt(codebuf, code, pi_arg) # :nodoc:
|
|
331
|
-
case pi_arg
|
|
332
|
-
when nil ; add_stmt(codebuf, code)
|
|
333
|
-
when 'header' ; @header = code
|
|
334
|
-
when 'footer' ; @footer = code
|
|
335
|
-
when 'comment'; add_stmt(codebuf, "\n" * code.count("\n"))
|
|
336
|
-
when 'value' ; add_expr_literal(codebuf, code)
|
|
337
|
-
else ; add_stmt(codebuf, code)
|
|
338
|
-
end
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
def add_pi_expr(codebuf, code, indicator) # :nodoc:
|
|
342
|
-
case indicator
|
|
343
|
-
when nil, '', '==' # @{...}@ or <%== ... %>
|
|
344
|
-
@escape == false ? add_expr_literal(codebuf, code) : add_expr_escaped(codebuf, code)
|
|
345
|
-
when '!', '=' # @!{...}@ or <%= ... %>
|
|
346
|
-
@escape == false ? add_expr_escaped(codebuf, code) : add_expr_literal(codebuf, code)
|
|
347
|
-
when '!!', '===' # @!!{...}@ or <%=== ... %>
|
|
348
|
-
add_expr_debug(codebuf, code)
|
|
349
|
-
else
|
|
350
|
-
# ignore
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
end
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
## $Release: 2.7.0 $
|
|
3
|
-
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
require 'erubis/engine'
|
|
7
|
-
require 'erubis/enhancer'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module Erubis
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module CGenerator
|
|
14
|
-
include Generator
|
|
15
|
-
|
|
16
|
-
def self.supported_properties() # :nodoc:
|
|
17
|
-
return [
|
|
18
|
-
[:indent, '', "indent spaces (ex. ' ')"],
|
|
19
|
-
[:out, 'stdout', "output file pointer name"],
|
|
20
|
-
]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def init_generator(properties={})
|
|
24
|
-
super
|
|
25
|
-
@escapefunc ||= "escape"
|
|
26
|
-
@indent = properties[:indent] || ''
|
|
27
|
-
@out = properties[:out] || 'stdout'
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def add_preamble(src)
|
|
31
|
-
src << "#line 1 \"#{self.filename}\"\n" if self.filename
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def escape_text(text)
|
|
35
|
-
@@table_ ||= { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" }
|
|
36
|
-
text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] }
|
|
37
|
-
return text
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def escaped_expr(code)
|
|
41
|
-
return "#{@escapefunc}(#{code.strip}, #{@out})"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def add_text(src, text)
|
|
45
|
-
return if text.empty?
|
|
46
|
-
src << (src.empty? || src[-1] == ?\n ? @indent : ' ')
|
|
47
|
-
src << "fputs("
|
|
48
|
-
i = 0
|
|
49
|
-
text.each_line do |line|
|
|
50
|
-
src << "\n" << @indent << ' ' if i > 0
|
|
51
|
-
i += 1
|
|
52
|
-
src << '"' << escape_text(line) << '"'
|
|
53
|
-
end
|
|
54
|
-
src << ", #{@out});" #<< (text[-1] == ?\n ? "\n" : "")
|
|
55
|
-
src << "\n" if text[-1] == ?\n
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def add_stmt(src, code)
|
|
59
|
-
src << code
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def add_expr_literal(src, code)
|
|
63
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
64
|
-
src << " fprintf(#{@out}, " << code.strip << ');'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def add_expr_escaped(src, code)
|
|
68
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
69
|
-
src << ' ' << escaped_expr(code) << ';'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def add_expr_debug(src, code)
|
|
73
|
-
code.strip!
|
|
74
|
-
s = nil
|
|
75
|
-
if code =~ /\A\".*?\"\s*,\s*(.*)/
|
|
76
|
-
s = $1.gsub(/[%"]/, '\\\1') + '='
|
|
77
|
-
end
|
|
78
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
79
|
-
src << " fprintf(stderr, \"*** debug: #{s}\" #{code});"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def add_postamble(src)
|
|
83
|
-
# empty
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
##
|
|
90
|
-
## engine for C
|
|
91
|
-
##
|
|
92
|
-
class Ec < Basic::Engine
|
|
93
|
-
include CGenerator
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class EscapedEc < Ec
|
|
98
|
-
include EscapeEnhancer
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
#class XmlEc < Ec
|
|
103
|
-
# include EscapeEnhancer
|
|
104
|
-
#end
|
|
105
|
-
|
|
106
|
-
class PI::Ec < PI::Engine
|
|
107
|
-
include CGenerator
|
|
108
|
-
|
|
109
|
-
def init_converter(properties={})
|
|
110
|
-
@pi = 'c'
|
|
111
|
-
super(properties)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
## $Release: 2.7.0 $
|
|
3
|
-
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
require 'erubis/engine'
|
|
7
|
-
require 'erubis/enhancer'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module Erubis
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module CppGenerator
|
|
14
|
-
include Generator
|
|
15
|
-
|
|
16
|
-
def self.supported_properties() # :nodoc:
|
|
17
|
-
return [
|
|
18
|
-
[:indent, '', "indent spaces (ex. ' ')"],
|
|
19
|
-
[:bufvar, '_buf', "buffer variable name"],
|
|
20
|
-
]
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def init_generator(properties={})
|
|
24
|
-
super
|
|
25
|
-
@escapefunc ||= "escape"
|
|
26
|
-
@indent = properties[:indent] || ''
|
|
27
|
-
@bufvar = properties[:bufvar] || '_buf'
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def add_preamble(src)
|
|
31
|
-
src << "#line 1 \"#{self.filename}\"\n" if self.filename
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def escape_text(text)
|
|
35
|
-
@@table_ ||= { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" }
|
|
36
|
-
text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] }
|
|
37
|
-
return text
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def escaped_expr(code)
|
|
41
|
-
return "#{@escapefunc}(#{code.strip})"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def add_text(src, text)
|
|
45
|
-
return if text.empty?
|
|
46
|
-
src << (src.empty? || src[-1] == ?\n ? @indent : ' ')
|
|
47
|
-
src << "_buf << "
|
|
48
|
-
i = 0
|
|
49
|
-
text.each_line do |line|
|
|
50
|
-
src << "\n" << @indent << " " if i > 0
|
|
51
|
-
i += 1
|
|
52
|
-
src << '"' << escape_text(line) << '"'
|
|
53
|
-
end
|
|
54
|
-
src << ";" #<< (text[-1] == ?\n ? "\n" : "")
|
|
55
|
-
src << "\n" if text[-1] == ?\n
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def add_stmt(src, code)
|
|
59
|
-
src << code
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def add_expr_literal(src, code)
|
|
63
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
64
|
-
src << " _buf << (" << code.strip << ");"
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def add_expr_escaped(src, code)
|
|
68
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
69
|
-
src << ' ' << escaped_expr(code) << ';'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def add_expr_debug(src, code)
|
|
73
|
-
code.strip!
|
|
74
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
75
|
-
src << " std::cerr << \"*** debug: #{code.gsub(/(")/, '\\\&')}=\" << (#{code});"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def add_postamble(src)
|
|
79
|
-
# empty
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
##
|
|
86
|
-
## engine for C
|
|
87
|
-
##
|
|
88
|
-
class Ecpp < Basic::Engine
|
|
89
|
-
include CppGenerator
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class EscapedEcpp < Ecpp
|
|
94
|
-
include EscapeEnhancer
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
#class XmlEcpp < Ecpp
|
|
99
|
-
# include EscapeEnhancer
|
|
100
|
-
#end
|
|
101
|
-
|
|
102
|
-
class PI::Ecpp < PI::Engine
|
|
103
|
-
include CppGenerator
|
|
104
|
-
|
|
105
|
-
def init_converter(properties={})
|
|
106
|
-
@pi = 'cpp'
|
|
107
|
-
super(properties)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
end
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
## $Release: 2.7.0 $
|
|
3
|
-
## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
require 'erubis/engine'
|
|
7
|
-
require 'erubis/enhancer'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module Erubis
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module JavaGenerator
|
|
14
|
-
include Generator
|
|
15
|
-
|
|
16
|
-
def self.supported_properties() # :nodoc:
|
|
17
|
-
return [
|
|
18
|
-
[:indent, '', "indent spaces (ex. ' ')"],
|
|
19
|
-
[:bufvar, '_buf', "output buffer variable name"],
|
|
20
|
-
[:bufclass, 'StringBuffer', "output buffer class (ex. 'StringBuilder')"],
|
|
21
|
-
]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def init_generator(properties={})
|
|
25
|
-
super
|
|
26
|
-
@escapefunc ||= 'escape'
|
|
27
|
-
@indent = properties[:indent] || ''
|
|
28
|
-
@bufvar = properties[:bufvar] || '_buf'
|
|
29
|
-
@bufclass = properties[:bufclass] || 'StringBuffer'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def add_preamble(src)
|
|
33
|
-
src << "#{@indent}#{@bufclass} #{@bufvar} = new #{@bufclass}();"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def escape_text(text)
|
|
37
|
-
@@table_ ||= { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" }
|
|
38
|
-
return text.gsub!(/[\r\n\t"\\]/) { |m| @@table_[m] } || text
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def add_text(src, text)
|
|
42
|
-
return if text.empty?
|
|
43
|
-
src << (src.empty? || src[-1] == ?\n ? @indent : ' ')
|
|
44
|
-
src << @bufvar << ".append("
|
|
45
|
-
i = 0
|
|
46
|
-
text.each_line do |line|
|
|
47
|
-
src << "\n" << @indent << ' + ' if i > 0
|
|
48
|
-
i += 1
|
|
49
|
-
src << '"' << escape_text(line) << '"'
|
|
50
|
-
end
|
|
51
|
-
src << ");" << (text[-1] == ?\n ? "\n" : "")
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def add_stmt(src, code)
|
|
55
|
-
src << code
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def add_expr_literal(src, code)
|
|
59
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
60
|
-
code.strip!
|
|
61
|
-
src << " #{@bufvar}.append(#{code});"
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def add_expr_escaped(src, code)
|
|
65
|
-
add_expr_literal(src, escaped_expr(code))
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def add_expr_debug(src, code)
|
|
69
|
-
code.strip!
|
|
70
|
-
src << @indent if src.empty? || src[-1] == ?\n
|
|
71
|
-
src << " System.err.println(\"*** debug: #{code}=\"+(#{code}));"
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def add_postamble(src)
|
|
75
|
-
src << "\n" if src[-1] == ?;
|
|
76
|
-
src << @indent << "return " << @bufvar << ".toString();\n"
|
|
77
|
-
#src << @indent << "System.out.print(" << @bufvar << ".toString());\n"
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
##
|
|
84
|
-
## engine for Java
|
|
85
|
-
##
|
|
86
|
-
class Ejava < Basic::Engine
|
|
87
|
-
include JavaGenerator
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class EscapedEjava < Ejava
|
|
92
|
-
include EscapeEnhancer
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
#class XmlEjava < Ejava
|
|
97
|
-
# include EscapeEnhancer
|
|
98
|
-
#end
|
|
99
|
-
|
|
100
|
-
class PI::Ejava < PI::Engine
|
|
101
|
-
include JavaGenerator
|
|
102
|
-
|
|
103
|
-
def init_converter(properties={})
|
|
104
|
-
@pi = 'java'
|
|
105
|
-
super(properties)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
end
|