Skip to content

Commit

Permalink
Fixed bug related to History (\&)
Browse files Browse the repository at this point in the history
  • Loading branch information
sleroux-keep committed Apr 9, 2013
1 parent c314928 commit 7384e01
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/wiki_controller_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def encrypt(originalText)
end

def decrypt(encodedContent)

e = OpenSSL::Cipher::Cipher.new 'DES-EDE3-CBC'
e.decrypt $key
s = encodedContent.to_a.pack("H*").unpack("C*").pack("c*")
s = e.update s
decoded = s << e.final

return decoded
end

Expand All @@ -57,12 +57,14 @@ def encode(originalText,params,history)
if history==1
params[:decode]='1'
originalText = decodeContent(originalText,params,1,0)
originalText = originalText.gsub(/\\/) { '\\\\' }
if Redmine::Configuration['database_cipher_key'].to_s.strip != ''
encrypted = encrypt(originalText)
originalText = '{{history_coded_start}}'+encrypted.strip+'{{history_coded_stop}}'
end
return originalText
else

matches = originalText.scan(/\{\{cipher\}\}.*?\{\{cipher\}\}/m)
matches.each do |m|
tagContent = m.gsub('{{cipher}}','')
Expand All @@ -76,6 +78,7 @@ def encode(originalText,params,history)
end
originalText = originalText.gsub(m.force_encoding("UTF-8"), codedTag.force_encoding("UTF-8"))
end
originalText = originalText.gsub(/\\\\/) { '\\' }
return originalText
end
end
Expand Down

0 comments on commit 7384e01

Please sign in to comment.