Sanitize image links and handle nils in the toc formatter. #5445
Based on contribution by Yuki Kita. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3811 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
68bdbbac7d
commit
6eea3300f8
|
@ -67,7 +67,9 @@ module Redmine
|
||||||
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
|
toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
|
||||||
# sanitizes titles from links
|
# sanitizes titles from links
|
||||||
# see redcloth3.rb, same as "#{pre}#{text}#{post}"
|
# see redcloth3.rb, same as "#{pre}#{text}#{post}"
|
||||||
toc_item.gsub!(LINK_RE) { $2+$4+$9 }
|
toc_item.gsub!(LINK_RE) { [$2, $4, $9].join }
|
||||||
|
# sanitizes image links from titles
|
||||||
|
toc_item.gsub!(IMAGE_RE) { [$5].join }
|
||||||
# removes styles
|
# removes styles
|
||||||
# eg. %{color:red}Triggers% => Triggers
|
# eg. %{color:red}Triggers% => Triggers
|
||||||
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
|
toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
|
||||||
|
|
|
@ -421,6 +421,9 @@ h2. Subtitle with %{color:red}red text%
|
||||||
h1. Another title
|
h1. Another title
|
||||||
|
|
||||||
h2. An "Internet link":http://www.redmine.org/ inside subtitle
|
h2. An "Internet link":http://www.redmine.org/ inside subtitle
|
||||||
|
|
||||||
|
h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
|
||||||
|
|
||||||
RAW
|
RAW
|
||||||
|
|
||||||
expected = '<ul class="toc">' +
|
expected = '<ul class="toc">' +
|
||||||
|
@ -430,8 +433,9 @@ RAW
|
||||||
'<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
|
'<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
|
||||||
'<li class="heading1"><a href="#Another-title">Another title</a></li>' +
|
'<li class="heading1"><a href="#Another-title">Another title</a></li>' +
|
||||||
'<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
|
'<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
|
||||||
|
'<li class="heading2"><a href="#Project-Name">Project Name</a></li>' +
|
||||||
'</ul>'
|
'</ul>'
|
||||||
|
|
||||||
assert textilizable(raw).gsub("\n", "").include?(expected)
|
assert textilizable(raw).gsub("\n", "").include?(expected)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue