##// 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 67 toc_item = content.gsub(/(\[\[([^\]\|]*)(\|([^\]]*))?\]\])/) { $4 || $2 }
68 68 # sanitizes titles from links
69 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 73 # removes styles
72 74 # eg. %{color:red}Triggers% => Triggers
73 75 toc_item.gsub! %r[%\{[^\}]*\}([^%]+)%], '\\1'
@@ -421,6 +421,9 h2. Subtitle with %{color:red}red text%
421 421 h1. Another title
422 422
423 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 427 RAW
425 428
426 429 expected = '<ul class="toc">' +
@@ -430,8 +433,9 RAW
430 433 '<li class="heading2"><a href="#Subtitle-with-red-text">Subtitle with red text</a></li>' +
431 434 '<li class="heading1"><a href="#Another-title">Another title</a></li>' +
432 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 437 '</ul>'
434
438
435 439 assert textilizable(raw).gsub("\n", "").include?(expected)
436 440 end
437 441
General Comments 0
You need to be logged in to leave comments. Login now