1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Fix that receiving HTML email fails if it contains a link without an href attribute (#31695).

Patch by Marius BALTEANU.


git-svn-id: http://svn.redmine.org/redmine/trunk@18988 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2019-11-09 06:06:05 +00:00
parent 09af8e6683
commit fc2e4c1eba
4 changed files with 32 additions and 2 deletions

View File

@ -37,7 +37,15 @@ module Redmine
'h6' => {:pre => "\n\n###### ", :post => "\n\n"},
'th' => {:pre => '*', :post => "*\n"},
'td' => {:pre => '', :post => "\n"},
'a' => lambda {|node| node.content.present? ? %| [#{node.content}](#{node.attributes['href'].value}) | : %| #{node.attributes['href'].value} |}
'a' => lambda do |node|
if node.content.present? && node.attributes.key?('href')
%| [#{node.content}](#{node.attributes['href'].value}) |
elsif node.attributes.key?('href')
%| #{node.attributes['href'].value} |
else
node.content
end
end
)
end
end

View File

@ -37,7 +37,15 @@ module Redmine
'h6' => {:pre => "\n\nh6. ", :post => "\n\n"},
'th' => {:pre => '*', :post => "*\n"},
'td' => {:pre => '', :post => "\n"},
'a' => lambda {|node| node.content.present? ? %| "#{node.content}":#{node.attributes['href'].value} | : %| #{node.attributes['href'].value} |}
'a' => lambda do |node|
if node.content.present? && node.attributes.key?('href')
%| "#{node.content}":#{node.attributes['href'].value} |
elsif node.attributes.key?('href')
%| #{node.attributes['href'].value} |
else
node.content
end
end
)
end
end

View File

@ -31,8 +31,15 @@ class Redmine::WikiFormatting::MarkdownHtmlParserTest < ActiveSupport::TestCase
assert_equal 'foo [bar](http://example.com/) baz',
@parser.to_text('foo<a href="http://example.com/">bar</a>baz')
assert_equal 'foo http://example.com/ baz',
@parser.to_text('foo<a href="http://example.com/"></a>baz')
assert_equal 'foobarbaz',
@parser.to_text('foo<a name="Header-one">bar</a>baz')
assert_equal 'foobaz',
@parser.to_text('foo<a name="Header-one"/>baz')
end
def test_html_tables_conversion

View File

@ -31,8 +31,15 @@ class Redmine::WikiFormatting::TextileHtmlParserTest < ActiveSupport::TestCase
assert_equal 'foo "bar":http://example.com/ baz',
@parser.to_text('foo<a href="http://example.com/">bar</a>baz')
assert_equal 'foo http://example.com/ baz',
@parser.to_text('foo<a href="http://example.com/"></a>baz')
assert_equal 'foobarbaz',
@parser.to_text('foo<a name="Header-one">bar</a>baz')
assert_equal 'foobaz',
@parser.to_text('foo<a name="Header-one"/>baz')
end
def test_html_tables_conversion