haml-edge 2.3.67 → 2.3.68
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/engine.rb +2 -5
- data/lib/haml/helpers/xss_mods.rb +3 -2
- data/lib/haml/precompiler.rb +11 -6
- data/test/haml/engine_test.rb +39 -0
- data/test/haml/template_test.rb +4 -0
- metadata +4 -4
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.68
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.68
|
data/lib/haml/engine.rb
CHANGED
@@ -110,7 +110,6 @@ module Haml
|
|
110
110
|
@precompiled = ''
|
111
111
|
@to_merge = []
|
112
112
|
@tab_change = 0
|
113
|
-
@temp_count = 0
|
114
113
|
|
115
114
|
precompile
|
116
115
|
rescue Haml::Error => e
|
@@ -179,15 +178,13 @@ module Haml
|
|
179
178
|
@haml_buffer = buffer
|
180
179
|
end
|
181
180
|
|
182
|
-
|
181
|
+
eval(precompiled + ";" + precompiled_method_return_value,
|
183
182
|
scope, @options[:filename], @options[:line])
|
184
|
-
|
183
|
+
ensure
|
185
184
|
# Get rid of the current buffer
|
186
185
|
scope_object.instance_eval do
|
187
186
|
@haml_buffer = buffer.upper
|
188
187
|
end
|
189
|
-
|
190
|
-
str
|
191
188
|
end
|
192
189
|
alias_method :to_html, :render
|
193
190
|
|
@@ -17,8 +17,9 @@ module Haml
|
|
17
17
|
# Don't escape text that's already safe,
|
18
18
|
# output is always HTML safe
|
19
19
|
def html_escape_with_haml_xss(text)
|
20
|
-
|
21
|
-
|
20
|
+
str = text.to_s
|
21
|
+
return text if str.html_safe?
|
22
|
+
html_escape_without_haml_xss(str).html_safe!
|
22
23
|
end
|
23
24
|
|
24
25
|
# Output is always HTML safe
|
data/lib/haml/precompiler.rb
CHANGED
@@ -92,14 +92,17 @@ module Haml
|
|
92
92
|
# Returns the precompiled string with the preamble and postamble
|
93
93
|
def precompiled_with_ambles(local_names)
|
94
94
|
preamble = <<END.gsub("\n", ";")
|
95
|
+
begin
|
95
96
|
extend Haml::Helpers
|
96
97
|
_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{options_for_buffer.inspect})
|
97
98
|
_erbout = _hamlout.buffer
|
98
99
|
__in_erb_template = true
|
99
100
|
END
|
100
101
|
postamble = <<END.gsub("\n", ";")
|
101
|
-
@haml_buffer = @haml_buffer.upper
|
102
102
|
#{precompiled_method_return_value}
|
103
|
+
ensure
|
104
|
+
@haml_buffer = @haml_buffer.upper
|
105
|
+
end
|
103
106
|
END
|
104
107
|
preamble + locals_code(local_names) + precompiled + postamble
|
105
108
|
end
|
@@ -1005,29 +1008,31 @@ END
|
|
1005
1008
|
|
1006
1009
|
def resolve_newlines
|
1007
1010
|
return unless @newlines > 0
|
1011
|
+
flush_merged_text unless @to_merge.all? {|type, *_| type == :text}
|
1008
1012
|
@precompiled << "\n" * @newlines
|
1009
1013
|
@newlines = 0
|
1010
1014
|
end
|
1011
1015
|
|
1012
1016
|
# Get rid of and whitespace at the end of the buffer
|
1013
1017
|
# or the merged text
|
1014
|
-
def rstrip_buffer!
|
1015
|
-
|
1018
|
+
def rstrip_buffer!(index = -1)
|
1019
|
+
last = @to_merge[index]
|
1020
|
+
if last.nil?
|
1016
1021
|
push_silent("_hamlout.rstrip!", false)
|
1017
1022
|
@dont_tab_up_next_text = true
|
1018
1023
|
return
|
1019
1024
|
end
|
1020
1025
|
|
1021
|
-
last = @to_merge.last
|
1022
1026
|
case last.first
|
1023
1027
|
when :text
|
1024
1028
|
last[1].rstrip!
|
1025
1029
|
if last[1].empty?
|
1026
|
-
@to_merge.
|
1027
|
-
rstrip_buffer!
|
1030
|
+
@to_merge.slice! index
|
1031
|
+
rstrip_buffer! index
|
1028
1032
|
end
|
1029
1033
|
when :script
|
1030
1034
|
last[1].gsub!(/\(haml_temp, (.*?)\);$/, '(haml_temp.rstrip, \1);')
|
1035
|
+
rstrip_buffer! index - 1
|
1031
1036
|
else
|
1032
1037
|
raise SyntaxError.new("[HAML BUG] Undefined entry in Haml::Precompiler@to_merge.")
|
1033
1038
|
end
|
data/test/haml/engine_test.rb
CHANGED
@@ -72,6 +72,7 @@ class EngineTest < Test::Unit::TestCase
|
|
72
72
|
"/ foo\n\n bar" => ["Illegal nesting: nesting within a tag that already has content is illegal.", 3],
|
73
73
|
"!!!\n\n bar" => ["Illegal nesting: nesting within a header command is illegal.", 3],
|
74
74
|
"foo\n:ruby\n 1\n 2\n 3\n- raise 'foo'" => ["foo", 6],
|
75
|
+
"= raise 'foo'\nfoo\nbar\nbaz\nbang" => ["foo", 1],
|
75
76
|
}
|
76
77
|
|
77
78
|
User = Struct.new('User', :id)
|
@@ -338,6 +339,18 @@ HTML
|
|
338
339
|
HAML
|
339
340
|
end
|
340
341
|
|
342
|
+
def test_outer_whitespace_nuke_with_empty_script
|
343
|
+
assert_equal(<<HTML, render(<<HAML))
|
344
|
+
<p>
|
345
|
+
foo<a></a></p>
|
346
|
+
HTML
|
347
|
+
%p
|
348
|
+
foo
|
349
|
+
= " "
|
350
|
+
%a>
|
351
|
+
HAML
|
352
|
+
end
|
353
|
+
|
341
354
|
def test_both_case_indentation_work_with_deeply_nested_code
|
342
355
|
result = <<RESULT
|
343
356
|
<h2>
|
@@ -973,6 +986,32 @@ END
|
|
973
986
|
assert_equal("FOO\n", engine("= upcase").render_proc("foo".instance_eval{binding}).call)
|
974
987
|
end
|
975
988
|
|
989
|
+
def test_haml_buffer_gets_reset_even_with_exception
|
990
|
+
scope = Object.new
|
991
|
+
render("- raise Haml::Error", :scope => scope)
|
992
|
+
assert(false, "Expected exception")
|
993
|
+
rescue Exception
|
994
|
+
assert_nil(scope.send(:haml_buffer))
|
995
|
+
end
|
996
|
+
|
997
|
+
def test_def_method_haml_buffer_gets_reset_even_with_exception
|
998
|
+
scope = Object.new
|
999
|
+
engine("- raise Haml::Error").def_method(scope, :render)
|
1000
|
+
scope.render
|
1001
|
+
assert(false, "Expected exception")
|
1002
|
+
rescue Exception
|
1003
|
+
assert_nil(scope.send(:haml_buffer))
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
def test_render_proc_haml_buffer_gets_reset_even_with_exception
|
1007
|
+
scope = Object.new
|
1008
|
+
proc = engine("- raise Haml::Error").render_proc(scope)
|
1009
|
+
proc.call
|
1010
|
+
assert(false, "Expected exception")
|
1011
|
+
rescue Exception
|
1012
|
+
assert_nil(scope.send(:haml_buffer))
|
1013
|
+
end
|
1014
|
+
|
976
1015
|
def test_ugly_true
|
977
1016
|
assert_equal("<div id='outer'>\n<div id='inner'>\n<p>hello world</p>\n</div>\n</div>\n",
|
978
1017
|
render("#outer\n #inner\n %p hello world", :ugly => true))
|
data/test/haml/template_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-11-03 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -44,8 +44,8 @@ extensions: []
|
|
44
44
|
|
45
45
|
extra_rdoc_files:
|
46
46
|
- README.md
|
47
|
-
- REVISION
|
48
47
|
- VERSION
|
48
|
+
- REVISION
|
49
49
|
- VERSION_NAME
|
50
50
|
- CONTRIBUTING
|
51
51
|
- MIT-LICENSE
|
@@ -262,8 +262,8 @@ files:
|
|
262
262
|
- init.rb
|
263
263
|
- .yardopts
|
264
264
|
- README.md
|
265
|
-
- REVISION
|
266
265
|
- VERSION
|
266
|
+
- REVISION
|
267
267
|
- VERSION_NAME
|
268
268
|
- CONTRIBUTING
|
269
269
|
- MIT-LICENSE
|