match-v2.diff

Go MAEDA, 2018-06-04 06:54

Download (13.6 KB)

View differences:

lib/plugins/open_id_authentication/lib/open_id_authentication.rb (working copy)
87 87
    # dodge XRIs -- TODO: validate, don't just skip.
88 88
    unless ['=', '@', '+', '$', '!', '('].include?(identifier.at(0))
89 89
      # does it begin with http?  if not, add it.
90
      identifier = "http://#{identifier}" unless identifier =~ /^http/i
90
      identifier = "http://#{identifier}" unless /^http/i.match?(identifier)
91 91

  
92 92
      # strip any fragments
93 93
      identifier.gsub!(/\#(.*)$/, '')
lib/redmine/codeset_util.rb (working copy)
39 39
      return str if str.nil?
40 40
      str.force_encoding('ASCII-8BIT')
41 41
      return str if str.empty?
42
      return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
42
      return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match?(str) # for us-ascii
43 43
      str.force_encoding('UTF-8')
44 44
      encodings = Setting.repositories_encodings.split(',').collect(&:strip)
45 45
      encodings.each do |encoding|
lib/redmine/configuration.rb (working copy)
114 114
      # Checks the validness of regular expressions set for repository paths at startup
115 115
      def check_regular_expressions
116 116
        @config.each do |name, value|
117
          if value.present? && name =~ /^scm_.+_path_regexp$/
117
          if value.present? && /^scm_.+_path_regexp$/.match?(name)
118 118
            begin
119 119
              Regexp.new value.to_s.strip
120 120
            rescue => e
lib/redmine/core_ext/active_record.rb (working copy)
19 19
  def validate_each(record, attribute, value)
20 20
    before_type_cast = record.attributes_before_type_cast[attribute.to_s]
21 21
    if before_type_cast.is_a?(String) && before_type_cast.present?
22
      unless before_type_cast =~ /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/ && value
22
      unless /\A\d{4}-\d{2}-\d{2}( 00:00:00)?\z/.match?(before_type_cast) && value
23 23
        record.errors.add attribute, :not_a_date
24 24
      end
25 25
    end
lib/redmine/export/pdf.rb (working copy)
141 141
        def self.attach(attachments, filename, encoding)
142 142
          filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
143 143
          atta = nil
144
          if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
144
          if /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i.match?(filename_utf8)
145 145
            atta = Attachment.latest_attach(attachments, filename_utf8)
146 146
          end
147 147
          if atta && atta.readable? && atta.visible?
lib/redmine/field_format.rb (working copy)
249 249
            [text, url]
250 250
          end
251 251
          links = texts_and_urls.sort_by(&:first).map do |text, url|
252
            css_class = (url =~ /^https?:\/\//) ? 'external' : nil
252
            css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
253 253
            view.link_to_if uri_with_safe_scheme?(url), text, url, :class => css_class
254 254
          end
255 255
          links.join(', ').html_safe
......
358 358
      def validate_single_value(custom_field, value, customized=nil)
359 359
        errs = super
360 360
        value = value.to_s
361
        unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
361
        unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value)
362 362
          errs << ::I18n.t('activerecord.errors.messages.invalid')
363 363
        end
364 364
        if custom_field.min_length && value.length < custom_field.min_length
......
440 440
            url = url_from_pattern(custom_field, value, customized)
441 441
          else
442 442
            url = value.to_s
443
            unless url =~ %r{\A[a-z]+://}i
443
            unless %r{\A[a-z]+://}i.match?(url)
444 444
              # no protocol found, use http by default
445 445
              url = "http://" + url
446 446
            end
447 447
          end
448
          css_class = (url =~ /^https?:\/\//) ? 'external' : nil
448
          css_class = (/^https?:\/\//.match?(url)) ? 'external' : nil
449 449
          view.link_to value.to_s.truncate(40), url, :class => css_class
450 450
        else
451 451
          value.to_s
......
490 490

  
491 491
      def validate_single_value(custom_field, value, customized=nil)
492 492
        errs = super
493
        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless value.to_s =~ /^[+-]?\d+$/
493
        errs << ::I18n.t('activerecord.errors.messages.not_a_number') unless /^[+-]?\d+$/.match?(value.to_s)
494 494
        errs
495 495
      end
496 496

  
......
534 534
      end
535 535

  
536 536
      def validate_single_value(custom_field, value, customized=nil)
537
        if value =~ /^\d{4}-\d{2}-\d{2}$/ && (value.to_date rescue false)
537
        if /^\d{4}-\d{2}-\d{2}$/.match?(value) && (value.to_date rescue false)
538 538
          []
539 539
        else
540 540
          [::I18n.t('activerecord.errors.messages.not_a_date')]
lib/redmine/platform.rb (working copy)
19 19
  module Platform
20 20
    class << self
21 21
      def mswin?
22
        (RUBY_PLATFORM =~ /(:?mswin|mingw)/) ||
23
           (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
22
        (/(:?mswin|mingw)/.match?(RUBY_PLATFORM)) ||
23
           (RUBY_PLATFORM == 'java' && /windows/i.match?(ENV['OS'] || ENV['os']))
24 24
      end
25 25
    end
26 26
  end
lib/redmine/scm/adapters/abstract_adapter.rb (working copy)
183 183

  
184 184
        def target(path, sq=true)
185 185
          path ||= ''
186
          base = path.match(/^\//) ? root_url : url
186
          base = /^\//.match?(path) ? root_url : url
187 187
          str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
188 188
          if sq
189 189
            str = shell_quote(str)
lib/redmine/scm/adapters/cvs_adapter.rb (working copy)
168 168
            file_state = nil
169 169
            branch_map = nil
170 170
            io.each_line() do |line|
171
              if state != "revision" && /^#{ENDLOG}/ =~ line
171
              if state != "revision" && /^#{ENDLOG}/.match?(line)
172 172
                commit_log = String.new
173 173
                revision   = nil
174 174
                state      = "entry_start"
......
181 181
                  logger.debug("Path #{entry_path} <=> Name #{entry_name}")
182 182
                elsif /^head: (.+)$/ =~ line
183 183
                  entry_headRev = $1 #unless entry.nil?
184
                elsif /^symbolic names:/ =~ line
184
                elsif /^symbolic names:/.match?(line)
185 185
                  state = "symbolic" #unless entry.nil?
186
                elsif /^#{STARTLOG}/ =~ line
186
                elsif /^#{STARTLOG}/.match?(line)
187 187
                  commit_log = String.new
188 188
                  state      = "revision"
189 189
                end
lib/redmine/scm/adapters/filesystem_adapter.rb (working copy)
107 107
        # Here we do not shell-out, so we do not want quotes.
108 108
        def target(path=nil)
109 109
          # Prevent the use of ..
110
          if path and !path.match(/(^|\/)\.\.(\/|$)/)
110
          if path and !/(^|\/)\.\.(\/|$)/.match?(path)
111 111
            return "#{self.url}#{without_leading_slash(path)}"
112 112
          end
113 113
          return self.url
lib/redmine/scm/adapters/mercurial_adapter.rb (working copy)
296 296
        # Runs 'hg' command with the given args
297 297
        def hg(*args, &block)
298 298
          # as of hg 4.4.1, early parsing of bool options is not terminated at '--'
299
          if args.any? { |s| s =~ HG_EARLY_BOOL_ARG }
299
          if args.any? { |s| HG_EARLY_BOOL_ARG.match?(s) }
300 300
            raise HgCommandArgumentError, "malicious command argument detected"
301 301
          end
302
          if args.take_while { |s| s != '--' }.any? { |s| s =~ HG_EARLY_LIST_ARG }
302
          if args.take_while { |s| s != '--' }.any? { |s| HG_EARLY_LIST_ARG.match?(s) }
303 303
            raise HgCommandArgumentError, "malicious command argument detected"
304 304
          end
305 305

  
lib/redmine/scm/adapters/subversion_adapter.rb (working copy)
265 265
        end
266 266

  
267 267
        def target(path = '')
268
          base = path.match(/^\//) ? root_url : url
268
          base = /^\//.match?(path) ? root_url : url
269 269
          uri = "#{base}/#{path}"
270 270
          uri = URI.escape(URI.escape(uri), '[]')
271 271
          shell_quote(uri.gsub(/[?<>\*]/, ''))
lib/redmine/sort_criteria.rb (working copy)
94 94

  
95 95
    # Appends ASC/DESC to the sort criterion unless it has a fixed order
96 96
    def append_order(criterion, order)
97
      if criterion =~ / (asc|desc)$/i
97
      if / (asc|desc)$/i.match?(criterion)
98 98
        criterion
99 99
      else
100 100
        "#{criterion} #{order.to_s.upcase}"
lib/redmine/unified_diff.rb (working copy)
76 76
          @parsing = true
77 77
        end
78 78
      else
79
        if line =~ %r{^[^\+\-\s@\\]}
79
        if %r{^[^\+\-\s@\\]}.match?(line)
80 80
          @parsing = false
81 81
          return false
82 82
        elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
......
112 112
    def file_name=(arg)
113 113
      both_git_diff = false
114 114
      if file_name.nil?
115
        @git_diff = true if arg =~ %r{^(a/|/dev/null)}
115
        @git_diff = true if %r{^(a/|/dev/null)}.match?(arg)
116 116
      else
117
        both_git_diff = (@git_diff && arg =~ %r{^(b/|/dev/null)})
117
        both_git_diff = (@git_diff && %r{^(b/|/dev/null)}.match?(arg))
118 118
      end
119 119
      if both_git_diff
120 120
        if file_name && arg == "/dev/null"
......
166 166
        true
167 167
      else
168 168
        write_offsets
169
        if line[0, 1] =~ /\s/
169
        if /\s/.match?(line[0, 1])
170 170
          diff = Diff.new
171 171
          diff.line_right = line[1..-1]
172 172
          diff.nb_line_right = @line_num_r
lib/redmine/wiki_formatting/macros.rb (working copy)
141 141
        # If a block of text is given, the closing tag }} must be at the start of a new line.
142 142
        def macro(name, options={}, &block)
143 143
          options.assert_valid_keys(:desc, :parse_args)
144
          unless name.to_s.match(/\A\w+\z/)
144
          unless /\A\w+\z/.match?(name.to_s)
145 145
            raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
146 146
          end
147 147
          unless block_given?
......
238 238
        filename = args.first
239 239
        raise 'Filename required' unless filename.present?
240 240
        size = options[:size]
241
        raise 'Invalid size parameter' unless size.nil? || size.match(/^\d+$/)
241
        raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size)
242 242
        size = size.to_i
243 243
        size = 200 unless size > 0
244 244
        if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
lib/redmine/wiki_formatting.rb (working copy)
133 133
      def auto_link!(text)
134 134
        text.gsub!(AUTO_LINK_RE) do
135 135
          all, leading, proto, url, post = $&, $1, $2, $3, $6
136
          if leading =~ /<a\s/i || leading =~ /![<>=]?/
136
          if  /<a\s/i.match?(leading) || /![<>=]?/.match?(leading)
137 137
            # don't replace URLs that are already linked
138 138
            # and URLs prefixed with ! !> !< != (textile images)
139 139
            all
......
155 155
      def auto_mailto!(text)
156 156
        text.gsub!(/((?<!@)\b[\w\.!#\$%\-+.\/]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
157 157
          mail = $1
158
          if text.match(/<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/)
158
          if /<a\b[^>]*>(.*)(#{Regexp.escape(mail)})(.*)<\/a>/.match?(text)
159 159
            mail
160 160
          else
161 161
            %(<a class="email" href="mailto:#{ERB::Util.html_escape mail}">#{ERB::Util.html_escape mail}</a>).html_safe