Permalink
Browse files

Register XSS-Settings correctly in Padrino::Mailer

Fixes #1059
  • Loading branch information...
skade committed Mar 10, 2013
1 parent 22a11cc commit 989b1b87212cd61173cb5431f4aece17b084baba
@@ -16,6 +16,9 @@ def initialize_with_app(*args, &block)
settings.views = File.expand_path("./mailers")
settings.reload_templates = true
end
+
+ initialize_template_settings!
+
# Run the original initialize
initialize_without_app(*args, &block)
end
@@ -246,5 +249,11 @@ def render(engine, data=nil, options={}, locals={}, &block)
self.body = super(engine, data, options, locals, &block) if provides.empty?
end
+ # register all special template configurations Padrino has to our fake settings object.
+ def initialize_template_settings!
+ Padrino::Rendering.engine_configurations.each do |name, value|
+ settings.class.instance_eval { define_method(name) { value } }
+ end
+ end
end # Message
end # Mail
@@ -1 +1 @@
-This is a body of text from a template
+This is a body of text from a template with interpolated <%= "<i>" %> and non-interpolated tags<br/>
@@ -68,7 +68,7 @@
assert_equal ['padrino@me.com'], email.from
assert_equal ['padrino@you.com'], email.to
assert_equal 'Hello there Padrino', email.subject
- assert_equal 'This is a body of text from a template', email.body.to_s.chomp
+ assert_equal 'This is a body of text from a template with interpolated &lt;i&gt; and non-interpolated tags<br/>', email.body.to_s.chomp
end
should 'send emails with scoped mailer defaults' do

0 comments on commit 989b1b8

Please sign in to comment.