summaryrefslogtreecommitdiffstats
path: root/lib/redmine
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-11-09 06:06:05 +0000
committerGo MAEDA <maeda@farend.jp>2019-11-09 06:06:05 +0000
commitfc2e4c1eba584205805a80dc4d7bb25d949a6840 (patch)
tree340dd367b2b4f8a327eaec6fe220942583f4e4ef /lib/redmine
parent09af8e66836a9084a483b552fe7341f72d8a81fb (diff)
downloadredmine-fc2e4c1eba584205805a80dc4d7bb25d949a6840.tar.gz
redmine-fc2e4c1eba584205805a80dc4d7bb25d949a6840.zip
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
Diffstat (limited to 'lib/redmine')
-rw-r--r--lib/redmine/wiki_formatting/markdown/html_parser.rb10
-rw-r--r--lib/redmine/wiki_formatting/textile/html_parser.rb10
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/redmine/wiki_formatting/markdown/html_parser.rb b/lib/redmine/wiki_formatting/markdown/html_parser.rb
index ff25a0bd2..636a3443e 100644
--- a/lib/redmine/wiki_formatting/markdown/html_parser.rb
+++ b/lib/redmine/wiki_formatting/markdown/html_parser.rb
@@ -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
diff --git a/lib/redmine/wiki_formatting/textile/html_parser.rb b/lib/redmine/wiki_formatting/textile/html_parser.rb
index 8623c2068..27dc5f975 100644
--- a/lib/redmine/wiki_formatting/textile/html_parser.rb
+++ b/lib/redmine/wiki_formatting/textile/html_parser.rb
@@ -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