haml-edge 2.3.159 → 2.3.160

Sign up to get free protection for your applications and to get access to all the features.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.159
1
+ 2.3.160
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.159
1
+ 2.3.160
@@ -45,10 +45,10 @@ module Haml
45
45
  # @yield A block in which all input to `#haml_concat` is treated as raw.
46
46
  # @see Haml::Util#rails_xss_safe?
47
47
  def with_raw_haml_concat
48
- @_haml_concat_raw = true
48
+ @_haml_concat_raw, old = true, @_haml_concat_raw
49
49
  yield
50
50
  ensure
51
- @_haml_concat_raw = false
51
+ @_haml_concat_raw = old
52
52
  end
53
53
  end
54
54
  end
@@ -125,7 +125,7 @@ module ActionView
125
125
  @template_object.send :is_haml?
126
126
  end
127
127
 
128
- unless defined?(ActionView::Helpers::ActiveRecordInstanceTag)
128
+ unless defined?(ActionView::Helpers) && defined?(ActionView::Helpers::ActiveRecordInstanceTag)
129
129
  alias_method :content_tag_without_haml, :content_tag
130
130
  alias_method :content_tag, :content_tag_with_haml
131
131
  end
data/lib/haml/helpers.rb CHANGED
@@ -539,12 +539,12 @@ MESSAGE
539
539
  # @yield A block in which the given buffer should be used
540
540
  def with_haml_buffer(buffer)
541
541
  @haml_buffer, old_buffer = buffer, @haml_buffer
542
- old_buffer.active, was_active = false, old_buffer.active? if old_buffer
543
- @haml_buffer.active = true
542
+ old_buffer.active, old_was_active = false, old_buffer.active? if old_buffer
543
+ @haml_buffer.active, was_active = true, @haml_buffer.active?
544
544
  yield
545
545
  ensure
546
- @haml_buffer.active = false
547
- old_buffer.active = was_active if old_buffer
546
+ @haml_buffer.active = was_active
547
+ old_buffer.active = old_was_active if old_buffer
548
548
  @haml_buffer = old_buffer
549
549
  end
550
550
 
@@ -3,8 +3,11 @@
3
3
 
4
4
  module Haml
5
5
  class Plugin < Haml::Util.av_template_class(:Handler)
6
- if defined?(ActionView::TemplateHandlers::Compilable) ||
7
- defined?(ActionView::Template::Handlers::Compilable)
6
+ if (defined?(ActionView::TemplateHandlers) &&
7
+ defined?(ActionView::TemplateHandlers::Compilable)) ||
8
+ (defined?(ActionView::Template) &&
9
+ defined?(ActionView::Template::Handlers) &&
10
+ defined?(ActionView::Template::Handlers::Compilable))
8
11
  include Haml::Util.av_template_class(:Handlers)::Compilable
9
12
  end
10
13
 
data/lib/haml/template.rb CHANGED
@@ -46,7 +46,8 @@ end
46
46
  # Decide how we want to load Haml into Rails.
47
47
  # Patching was necessary for versions <= 2.0.1,
48
48
  # but we can make it a normal handler for higher versions.
49
- if defined?(ActionView::TemplateHandler) || defined?(ActionView::Template::Handler)
49
+ if defined?(ActionView::TemplateHandler) ||
50
+ (defined?(ActionView::Template) && defined?(ActionView::Template::Handler))
50
51
  require 'haml/template/plugin'
51
52
  else
52
53
  require 'haml/template/patch'
data/lib/sass/files.rb CHANGED
@@ -98,7 +98,7 @@ END
98
98
  return unless f.readline("\n").strip == sha
99
99
  return Marshal.load(f.read)
100
100
  end
101
- rescue TypeError, ArgumentError => e
101
+ rescue EOFError, TypeError, ArgumentError => e
102
102
  warn "Warning. Error encountered while reading cache #{compiled_filename}: #{e}"
103
103
  end
104
104
 
@@ -48,12 +48,12 @@ module Sass
48
48
  # This is automatically done once the Rack plugin is activated.
49
49
  # This is done so that the stylesheets aren't checked twice for each request.
50
50
  def self.disable_native_plugin!
51
- if defined?(Merb::Rack::Application) &&
51
+ if defined?(Merb::Rack) && defined?(Merb::Rack::Application) &&
52
52
  Haml::Util.has?(:instance_method, Merb::Rack::Application, :call_without_sass)
53
53
  Merb::Rack::Application.instance_eval {alias_method :call, :call_without_sass}
54
54
  end
55
55
 
56
- if defined?(ActionDispatch::Callbacks.to_prepare)
56
+ if defined?(ActionDispatch::Callbacks) && defined?(ActionDispatch::Callbacks.to_prepare)
57
57
  ActionDispatch::Callbacks.skip_callback(:prepare, :__sass_process)
58
58
  elsif defined?(ActionController::Base) &&
59
59
  Haml::Util.has?(:instance_method, ActionController::Base, :sass_old_process)
@@ -7,11 +7,12 @@ unless defined?(Sass::RAILS_LOADED)
7
7
  :always_check => Haml::Util.rails_env != "production",
8
8
  :full_exception => Haml::Util.rails_env != "production")
9
9
 
10
- if defined?(Rails.configuration.middleware)
10
+ if defined?(Rails.configuration) && defined?(Rails.configuration.middleware)
11
11
  # Rails >= 3.0
12
12
  require 'sass/plugin/rack'
13
13
  Rails.configuration.middleware.use(Sass::Plugin::Rack)
14
- elsif defined?(ActionController::Dispatcher.middleware)
14
+ elsif defined?(ActionController::Dispatcher) &&
15
+ defined?(ActionController::Dispatcher.middleware)
15
16
  # Rails >= 2.3
16
17
  require 'sass/plugin/rack'
17
18
  ActionController::Dispatcher.middleware.use(Sass::Plugin::Rack)
@@ -309,6 +309,20 @@ END
309
309
 
310
310
  ## Regression
311
311
 
312
+ def test_xss_protection_with_nested_haml_tag
313
+ assert_equal(<<HTML, render(<<HAML, :action_view))
314
+ <div>
315
+ <ul>
316
+ <li>Content!</li>
317
+ </ul>
318
+ </div>
319
+ HTML
320
+ - haml_tag :div do
321
+ - haml_tag :ul do
322
+ - haml_tag :li, "Content!"
323
+ HAML
324
+ end
325
+
312
326
  def test_xss_protection_with_form_for
313
327
  assert_equal(<<HTML, render(<<HAML, :action_view))
314
328
  <form action="" method="post">
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.159
4
+ version: 2.3.160
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum