Project

General

Profile

Patch #35217 » 0001-replaces-uses-of-Digest-MD5-and-Digest-SHA1-with-AS-.patch

Jens Krämer, 2021-05-07 05:01

View differences:

app/controllers/repositories_controller.rb
277 277
        User.current.preference.save
278 278
      end
279 279
      @cache_key = "repositories/diff/#{@repository.id}/" +
280
                      Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
280
                      ActiveSupport::Digest.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}")
281 281
      unless read_fragment(@cache_key)
282 282
        @diff = @repository.diff(@path, @rev, @rev_to)
283 283
        (show_error_not_found; return) unless @diff
app/models/attachment.rb
134 134
  end
135 135

  
136 136
  # Copies the temporary file to its final location
137
  # and computes its MD5 hash
137
  # and computes its hash
138 138
  def files_to_final_location
139 139
    if @temp_file
140 140
      self.disk_directory = target_directory
......
565 565
      if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
566 566
        ascii = filename
567 567
      else
568
        ascii = Digest::MD5.hexdigest(filename)
568
        ascii = ActiveSupport::Digest.hexdigest(filename)
569 569
        # keep the extension if any
570 570
        ascii << $1 if filename =~ %r{(\.[a-zA-Z0-9]+)$}
571 571
      end
app/views/repositories/_dir_list_content.html.erb
1 1
<% @entries.each do |entry| %>
2
<% tr_id = Digest::MD5.hexdigest(entry.path)
2
<% tr_id = ActiveSupport::Digest.hexdigest(entry.path)
3 3
   depth = params[:depth].to_i %>
4 4
<%  ent_path = Redmine::CodesetUtil.replace_invalid_utf8(entry.path)   %>
5 5
<%  ent_name = Redmine::CodesetUtil.replace_invalid_utf8(entry.name)   %>
lib/plugins/open_id_authentication/lib/open_id_authentication/mem_cache_store.rb
1 1
# frozen_string_literal: false
2 2

  
3
require 'digest/sha1'
4 3
require 'openid/store/interface'
5 4

  
6 5
module OpenIdAuthentication
......
69 68
      end
70 69

  
71 70
      def digest(text)
72
        Digest::SHA1.hexdigest(text)
71
        ActiveSupport::Digest.hexdigest(text)
73 72
      end
74 73
  end
75 74
end
lib/redmine/wiki_formatting.rb
17 17
# along with this program; if not, write to the Free Software
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20
require 'digest/md5'
21

  
22 20
module Redmine
23 21
  module WikiFormatting
24 22
    class StaleSectionError < StandardError; end
......
105 103
      # Returns a cache key for the given text +format+, +text+, +object+ and +attribute+ or nil if no caching should be done
106 104
      def cache_key_for(format, text, object, attribute)
107 105
        if object && attribute && !object.new_record? && format.present?
108
          "formatted_text/#{format}/#{object.class.model_name.cache_key}/#{object.id}-#{attribute}-#{Digest::MD5.hexdigest text}"
106
          "formatted_text/#{format}/#{object.class.model_name.cache_key}/#{object.id}-#{attribute}-#{ActiveSupport::Digest.hexdigest text}"
109 107
        end
110 108
      end
111 109

  
lib/redmine/wiki_formatting/markdown/formatter.rb
69 69

  
70 70
        def get_section(index)
71 71
          section = extract_sections(index)[1]
72
          hash = Digest::MD5.hexdigest(section)
72
          hash = ActiveSupport::Digest.hexdigest(section)
73 73
          return section, hash
74 74
        end
75 75

  
76 76
        def update_section(index, update, hash=nil)
77 77
          t = extract_sections(index)
78
          if hash.present? && hash != Digest::MD5.hexdigest(t[1])
78
          if hash.present? && hash != ActiveSupport::Digest.hexdigest(t[1])
79 79
            raise Redmine::WikiFormatting::StaleSectionError
80 80
          end
81 81

  
lib/redmine/wiki_formatting/textile/formatter.rb
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20 20
require File.expand_path('../redcloth3', __FILE__)
21
require 'digest/md5'
22 21

  
23 22
module Redmine
24 23
  module WikiFormatting
......
48 47

  
49 48
        def get_section(index)
50 49
          section = extract_sections(index)[1]
51
          hash = Digest::MD5.hexdigest(section)
50
          hash = ActiveSupport::Digest.hexdigest(section)
52 51
          return section, hash
53 52
        end
54 53

  
55 54
        def update_section(index, update, hash=nil)
56 55
          t = extract_sections(index)
57
          if hash.present? && hash != Digest::MD5.hexdigest(t[1])
56
          if hash.present? && hash != ActiveSupport::Digest.hexdigest(t[1])
58 57
            raise Redmine::WikiFormatting::StaleSectionError
59 58
          end
60 59

  
test/functional/wiki_controller_test.rb
632 632
              :version => 3
633 633
            },
634 634
            :section => 2,
635
            :section_hash => Digest::MD5.hexdigest("wrong hash")
635
            :section_hash => ActiveSupport::Digest.hexdigest("wrong hash")
636 636
          }
637 637
        end
638 638
      end
test/helpers/avatars_helper_test.rb
31 31
  end
32 32

  
33 33
  def test_avatar_with_user
34
    assert_include Digest::MD5.hexdigest('jsmith@somenet.foo'), avatar(User.find_by_mail('jsmith@somenet.foo'))
34
    assert_include ActiveSupport::Digest.hexdigest('jsmith@somenet.foo'), avatar(User.find_by_mail('jsmith@somenet.foo'))
35 35
  end
36 36

  
37 37
  def test_avatar_with_email_string
38
    assert_include Digest::MD5.hexdigest('jsmith@somenet.foo'), avatar('jsmith <jsmith@somenet.foo>')
38
    assert_include ActiveSupport::Digest.hexdigest('jsmith@somenet.foo'), avatar('jsmith <jsmith@somenet.foo>')
39 39
  end
40 40

  
41 41
  def test_avatar_with_anonymous_user
test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
193 193
    assert_kind_of Array, result
194 194
    assert_equal 2, result.size
195 195
    assert_equal expected, result.first, "section content did not match"
196
    assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
196
    assert_equal ActiveSupport::Digest.hexdigest(expected), result.last, "section hash did not match"
197 197
  end
198 198
end
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
19 19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 20

  
21 21
require File.expand_path('../../../../../test_helper', __FILE__)
22
require 'digest/md5'
23 22

  
24 23
class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
25 24
  def setup
......
491 490
    assert_equal(
492 491
      [STR_WITHOUT_PRE[0], replacement, STR_WITHOUT_PRE[2..4]].flatten.join("\n\n"),
493 492
      @formatter.new(TEXT_WITHOUT_PRE).
494
        update_section(2, replacement, Digest::MD5.hexdigest(STR_WITHOUT_PRE[1]))
493
        update_section(2, replacement, ActiveSupport::Digest.hexdigest(STR_WITHOUT_PRE[1]))
495 494
    )
496 495
  end
497 496

  
498 497
  def test_update_section_with_wrong_hash_should_raise_an_error
499 498
    assert_raise Redmine::WikiFormatting::StaleSectionError do
500
      @formatter.new(TEXT_WITHOUT_PRE).update_section(2, "New text", Digest::MD5.hexdigest("Old text"))
499
      @formatter.new(TEXT_WITHOUT_PRE).update_section(2, "New text", ActiveSupport::Digest.hexdigest("Old text"))
501 500
    end
502 501
  end
503 502

  
......
725 724
    assert_kind_of Array, result
726 725
    assert_equal 2, result.size
727 726
    assert_equal expected, result.first, "section content did not match"
728
    assert_equal Digest::MD5.hexdigest(expected), result.last, "section hash did not match"
727
    assert_equal ActiveSupport::Digest.hexdigest(expected), result.last, "section hash did not match"
729 728
  end
730 729
end
    (1-1/1)