Reputation: 4116
Im on ruby 1.9.3p545 and Rails 3.0.20
I have a contact form and I'm sending the following email to the user when they fill it up:
Thank you for your inquiry Beverly, This email is a receipt to confirm we have received your inquiry and `we'll` be in touch shortly.
My issue is it's showing we'll
instead of showing we'll
, what would I need to do display the message properly?
My controller create action:
def create
@inquiry = Inquiry.new(params[:inquiry])
if @inquiry.save
if @inquiry.ham?
begin
InquiryMailer.notification(@inquiry, request).deliver
rescue
logger.warn "There was an error delivering an inquiry notification.\n#{$!}\n"
end
begin
InquiryMailer.confirmation(@inquiry, request).deliver
rescue
logger.warn "There was an error delivering an inquiry confirmation:\n#{$!}\n"
end
end
redirect_to thank_you_inquiries_url
else
render :action => 'new'
end
end
I'm using it on refinery-cms
on app/views/inquiry_mailer/confirmation.html.erb
I have: <%= InquirySetting.confirmation_message(Globalize.locale).gsub("%name%", @inquiry.name) %>
and on refinery settings have the following email:
Thank you for your inquiry %name%,
This email is a receipt to confirm we have received your inquiry and we'll be in touch shortly.
Any help would be greatly appreciated!
Upvotes: 0
Views: 88
Reputation: 2242
Rails sanitises the string of InquirySetting.confirmation_message(Globalize.locale).gsub("%name%", @inquiry.name)
. It does this in order to prevent html tags and the like within possibly user provided strings to be rendered by the server. Otherwise your application would be open to XSS attacks.
If you know the string for the confirmation_message to not be user changeable contents you can deactivate Rails' security mechanism by declaring the string as safe. Do so by changing the contents of the template to <%= raw InquirySetting.confirmation_message(Globalize.locale).gsub("%name%", @inquiry.name) %>
.
Again, please only do so if you trust the source of the template's contents.
Upvotes: 2