diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-08-17 14:46:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-08-17 14:46:55 +0000 |
commit | 73aece0bafb918468d89c00550aaaed35c1d2efb (patch) | |
tree | 41fb309e46eb172b1391d1256a04fe90ce6a0a9d /lib/redmine/wiki_formatting.rb | |
parent | af5a814f4cf11d3c288b00e0b7b9d89b7a5ef74d (diff) | |
download | redmine-73aece0bafb918468d89c00550aaaed35c1d2efb.tar.gz redmine-73aece0bafb918468d89c00550aaaed35c1d2efb.zip |
Macros processing overhaul (#3061, #11633).
* macro arguments are no longer parsed by text formatters
* macro output is escaped unless it's html safe
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10209 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting.rb')
-rw-r--r-- | lib/redmine/wiki_formatting.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb index 6bff28d01..800200e14 100644 --- a/lib/redmine/wiki_formatting.rb +++ b/lib/redmine/wiki_formatting.rb @@ -15,6 +15,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +require 'digest/md5' + module Redmine module WikiFormatting class StaleSectionError < Exception; end @@ -50,7 +52,7 @@ module Redmine end def to_html(format, text, options = {}) - text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, options[:object], options[:attribute]) + text = if Setting.cache_formatted_text? && text.size > 2.kilobyte && cache_store && cache_key = cache_key_for(format, text, options[:object], options[:attribute]) # Text retrieved from the cache store may be frozen # We need to dup it so we can do in-place substitutions with gsub! cache_store.fetch cache_key do @@ -67,10 +69,10 @@ module Redmine (formatter.instance_methods & ['update_section', :update_section]).any? end - # Returns a cache key for the given text +format+, +object+ and +attribute+ or nil if no caching should be done - def cache_key_for(format, object, attribute) - if object && attribute && !object.new_record? && object.respond_to?(:updated_on) && !format.blank? - "formatted_text/#{format}/#{object.class.model_name.cache_key}/#{object.id}-#{attribute}-#{object.updated_on.to_s(:number)}" + # Returns a cache key for the given text +format+, +text+, +object+ and +attribute+ or nil if no caching should be done + def cache_key_for(format, text, object, attribute) + if object && attribute && !object.new_record? && format.present? + "formatted_text/#{format}/#{object.class.model_name.cache_key}/#{object.id}-#{attribute}-#{Digest::MD5.hexdigest text}" end end |