##// END OF EJS Templates
Sanitize image links and handle nils in the toc formatter. #5445...
Eric Davis -
r3697:6eea3300f88a
parent child
Show More
@@ -67,7 +67,9 module Redmine
67 toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
67 toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
68 # sanitizes titles from links
68 # sanitizes titles from links
69 # see redcloth3.rb, same as "#{pre}#{text}#{post}"
69 # see redcloth3.rb, same as "#{pre}#{text}#{post}"
70 toc_item.gsub!(LINK_RE) { $2+$4+$9 }
70 toc_item.gsub!(LINK_RE) { [$2, $4, $9].join }
71 # sanitizes image links from titles
72 toc_item.gsub!(IMAGE_RE) { [$5].join }
71 # removes styles
73 # removes styles
72 # eg. %{color:red}Triggers% => Triggers
74 # eg. %{color:red}Triggers% => Triggers
73 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
75 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
@@ -421,6 +421,9 h2. Subtitle with %{color:red}red text%
421 h1. Another title
421 h1. Another title
422
422
423 h2. An "Internet link":http://www.redmine.org/ inside subtitle
423 h2. An "Internet link":http://www.redmine.org/ inside subtitle
424
425 h2. "Project Name !/attachments/1234/logo_small.gif! !/attachments/5678/logo_2.png!":/projects/projectname/issues
426
424 RAW
427 RAW
425
428
426 expected = '<ul class="toc">' +
429 expected = '<ul class="toc">' +
@@ -430,8 +433,9 RAW
430 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
433 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
431 '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
434 '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
432 '<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
435 '<li class="heading2"><a href="#An-Internet-link-inside-subtitle">An Internet link inside subtitle</a></li>' +
436 '<li class="heading2"><a href="#Project-Name">Project Name</a></li>' +
433 '</ul>'
437 '</ul>'
434
438
435 assert textilizable(raw).gsub("\n", "").include?(expected)
439 assert textilizable(raw).gsub("\n", "").include?(expected)
436 end
440 end
437
441
General Comments 0
You need to be logged in to leave comments. Login now