Skip to content

Commit

Permalink
Use div macros for header/footer inclusion
Browse files Browse the repository at this point in the history
In this changeset I removed <div> from allowed tags as it makes it
possible to post arbitrary <div> tags in journals with @<div>@ markup.

It was originally put there to avoid issue with <p> tag wrapping of
included header/footer blocks by macros.

I found a workaround in current Textile parser which allows to disable
wrapping of macros. This can be done by adding "<code></code>" in the
beginning of the line. This way the rest of the line is rendered as is
without being put in a paragraph.

This behavior may change in RedCloth4, but Redmine is still not there so
we can use this workaround for a while, before Redmine comes up with an
appropriate way to disable paragraphs.

fixes #8
related https://code.google.com/archive/p/redminewikiext/issues/4
related https://redmine.org/issues/29588
related https://redmine.org/issues/13695
  • Loading branch information
cmrd-senya committed Sep 11, 2018
1 parent 38c66a8 commit 2e4df44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
require 'config/initializers/session_store.rb'
rescue LoadError
end
require 'redmine/wiki_formatting/textile/redcloth3'

require_dependency 'wiki_extensions_notifiable_patch'
Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file|
Expand Down Expand Up @@ -90,7 +89,5 @@
:if => Proc.new{|proj| WikiExtensionsMenu.enabled?(proj.id, no)}
}

RedCloth3::ALLOWED_TAGS << "div"

activity_provider :wiki_comment, :class_name => 'WikiExtensionsComment', :default => false
end
8 changes: 4 additions & 4 deletions lib/wiki_extensions_wiki_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def wiki_extensions_include_header
header = @wiki.find_page('Header')
return unless header
text = "\n"
text << '<div id="wiki_extentions_header">'
text << '<code></code>{{div_start_tag(wiki_extentions_header)}}'
text << "\n\n"
text << header.content.text
text << "\n\n</div>"
text << "\n\n<code></code>{{div_end_tag}}"
text << "\n\n"
text << @content.text
@content.text = text
Expand All @@ -105,10 +105,10 @@ def wiki_extensions_include_footer
return unless footer
text = @content.text
text << "\n"
text << '<div id="wiki_extentions_footer">'
text << '<code></code>{{div_start_tag(wiki_extentions_footer)}}'
text << "\n\n"
text << footer.content.text
text << "\n\n</div>"
text << "\n\n<code></code>{{div_end_tag}}"

end
end
Expand Down

0 comments on commit 2e4df44

Please sign in to comment.