From 7666d4d150bc48a6dad4a058d530b50b7824a9d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Jachymczyk?= <lukasz.jachymczyk@sology.pl>
Date: Tue, 26 Jun 2012 13:25:47 +0200
Subject: [PATCH] Fix escaping of html links in wiki mailer notification.

---
 app/views/mailer/wiki_content_added.html.erb   |    2 +-
 app/views/mailer/wiki_content_updated.html.erb |    2 +-
 test/unit/mailer_test.rb                       |   10 ++++++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/app/views/mailer/wiki_content_added.html.erb b/app/views/mailer/wiki_content_added.html.erb
index 160f573..8c83f62 100644
--- a/app/views/mailer/wiki_content_added.html.erb
+++ b/app/views/mailer/wiki_content_added.html.erb
@@ -1,3 +1,3 @@
 <p><%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
-                                        :author => h(@wiki_content.author)) %><br />
+                                        :author => h(@wiki_content.author)).html_safe %><br />
 <em><%=h @wiki_content.comments %></em></p>
diff --git a/app/views/mailer/wiki_content_updated.html.erb b/app/views/mailer/wiki_content_updated.html.erb
index 8ef24d1..f1f3857 100644
--- a/app/views/mailer/wiki_content_updated.html.erb
+++ b/app/views/mailer/wiki_content_updated.html.erb
@@ -1,5 +1,5 @@
 <p><%= l(:mail_body_wiki_content_updated, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
-                                          :author => h(@wiki_content.author)) %><br />
+                                          :author => h(@wiki_content.author)).html_safe %><br />
 <em><%=h @wiki_content.comments %></em></p>
 
 <p><%= l(:label_view_diff) %>:<br />
diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb
index 0bf62cf..3721ad4 100644
--- a/test/unit/mailer_test.rb
+++ b/test/unit/mailer_test.rb
@@ -404,6 +404,11 @@ class MailerTest < ActiveSupport::TestCase
       Setting.default_language = lang.to_s
       assert_difference 'ActionMailer::Base.deliveries.size' do
         assert Mailer.wiki_content_added(content).deliver
+        assert_select_email do
+          assert_select 'a[href=?]',
+            'http://mydomain.foo/projects/ecookbook/wiki/CookBook_documentation',
+            :text => 'CookBook documentation'
+        end
       end
     end
   end
@@ -414,6 +419,11 @@ class MailerTest < ActiveSupport::TestCase
       Setting.default_language = lang.to_s
       assert_difference 'ActionMailer::Base.deliveries.size' do
         assert Mailer.wiki_content_updated(content).deliver
+        assert_select_email do
+          assert_select 'a[href=?]',
+            'http://mydomain.foo/projects/ecookbook/wiki/CookBook_documentation',
+            :text => 'CookBook documentation'
+        end
       end
     end
   end
-- 
1.7.10.1

