mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 05:01:44 +08:00
FIX: Remove html entities from text emails
This commit is contained in:
parent
55fc54fe69
commit
b1271ed44b
|
@ -11,6 +11,7 @@ module Email
|
||||||
def text
|
def text
|
||||||
return @text if @text
|
return @text if @text
|
||||||
@text = (@message.text_part ? @message.text_part : @message).body.to_s.force_encoding('UTF-8')
|
@text = (@message.text_part ? @message.text_part : @message).body.to_s.force_encoding('UTF-8')
|
||||||
|
@text = CGI.unescapeHTML(@text)
|
||||||
end
|
end
|
||||||
|
|
||||||
def html
|
def html
|
||||||
|
@ -28,4 +29,4 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
29
spec/components/email/renderer_spec.rb
Normal file
29
spec/components/email/renderer_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'email/renderer'
|
||||||
|
|
||||||
|
describe Email::Renderer do
|
||||||
|
|
||||||
|
let(:message) do
|
||||||
|
mail = Mail.new
|
||||||
|
|
||||||
|
mail.text_part = Mail::Part.new do
|
||||||
|
body 'Key & Peele'
|
||||||
|
end
|
||||||
|
|
||||||
|
mail.html_part = Mail::Part.new do
|
||||||
|
content_type 'text/html; charset=UTF-8'
|
||||||
|
body '<h1>Key & Peele</h1>'
|
||||||
|
end
|
||||||
|
|
||||||
|
mail
|
||||||
|
end
|
||||||
|
|
||||||
|
it "escapes HTML entities from text" do
|
||||||
|
renderer = Email::Renderer.new(message)
|
||||||
|
renderer.text.should == "Key & Peele"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user