Project

General

Profile

Patch #28940 » match_final.patch

Pavel Rosický, 2018-06-17 18:14

View differences:

app/controllers/application_controller.rb (working copy)
112 112
      if (key = api_key_from_request)
113 113
        # Use API key
114 114
        user = User.find_by_api_key(key)
115
      elsif request.authorization.to_s =~ /\ABasic /i
115
      elsif /\ABasic /i.match?(request.authorization.to_s)
116 116
        # HTTP Basic, either username/password or API key/random
117 117
        authenticate_with_http_basic do |username, password|
118 118
          user = User.try_to_login(username, password) || User.find_by_api_key(username)
......
438 438
    path = uri.to_s
439 439
    # Ensure that the remaining URL starts with a slash, followed by a
440 440
    # non-slash character or the end
441
    if path !~ %r{\A/([^/]|\z)}
441
    if !%r{\A/([^/]|\z)}.match?(path)
442 442
      return false
443 443
    end
444 444

  
445
    if path.match(%r{/(login|account/register|account/lost_password)})
445
    if %r{/(login|account/register|account/lost_password)}.match?(path)
446 446
      return false
447 447
    end
448 448

  
......
623 623

  
624 624
  # Returns a string that can be used as filename value in Content-Disposition header
625 625
  def filename_for_content_disposition(name)
626
    request.env['HTTP_USER_AGENT'] =~ %r{(MSIE|Trident|Edge)} ? ERB::Util.url_encode(name) : name
626
    %r{(MSIE|Trident|Edge)}.match?(request.env['HTTP_USER_AGENT']) ? ERB::Util.url_encode(name) : name
627 627
  end
628 628

  
629 629
  def api_request?
app/controllers/repositories_controller.rb (working copy)
311 311
    @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
312 312
    @rev_to = params[:rev_to]
313 313

  
314
    unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
314
    unless REV_PARAM_RE.match?(@rev.to_s) && REV_PARAM_RE.match?(@rev_to.to_s)
315 315
      if @repository.branches.blank?
316 316
        raise InvalidRevisionParam
317 317
      end
app/controllers/sys_controller.rb (working copy)
50 50
    scope = Project.active.has_module(:repository)
51 51
    if params[:id]
52 52
      project = nil
53
      if params[:id].to_s =~ /^\d*$/
53
      if /^\d*$/.match?(params[:id].to_s)
54 54
        project = scope.find(params[:id])
55 55
      else
56 56
        project = scope.find_by_identifier(params[:id])
app/helpers/queries_helper.rb (working copy)
30 30
        group = :label_relations
31 31
      elsif field_options[:type] == :tree
32 32
        group = query.is_a?(IssueQuery) ? :label_relations : nil
33
      elsif field =~ /^cf_\d+\./
33
      elsif /^cf_\d+\./.match?(field)
34 34
        group = (field_options[:through] || field_options[:field]).try(:name)
35 35
      elsif field =~ /^(.+)\./
36 36
        # association filters
app/models/attachment.rb (working copy)
243 243
  end
244 244

  
245 245
  def is_diff?
246
    self.filename =~ /\.(patch|diff)$/i
246
    /\.(patch|diff)$/i.match?(filename)
247 247
  end
248 248

  
249 249
  def is_pdf?
......
484 484
  def self.disk_filename(filename, directory=nil)
485 485
    timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
486 486
    ascii = ''
487
    if filename =~ %r{^[a-zA-Z0-9_\.\-]*$} && filename.length <= 50
487
    if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
488 488
      ascii = filename
489 489
    else
490 490
      ascii = Digest::MD5.hexdigest(filename)
app/models/import.rb (working copy)
77 77
  # Returns the full path of the file to import
78 78
  # It is stored in tmp/imports with a random hex as filename
79 79
  def filepath
80
    if filename.present? && filename =~ /\A[0-9a-f]+\z/
80
    if filename.present? && /\A[0-9a-f]+\z/.match?(filename)
81 81
      File.join(Rails.root, "tmp", "imports", filename)
82 82
    else
83 83
      nil
app/models/issue.rb (working copy)
521 521

  
522 522
    # Project and Tracker must be set before since new_statuses_allowed_to depends on it.
523 523
    if (p = attrs.delete('project_id')) && safe_attribute?('project_id')
524
      if p.is_a?(String) && !p.match(/^\d*$/)
524
      if p.is_a?(String) && !/^\d*$/.match?(p)
525 525
        p_id = Project.find_by_identifier(p).try(:id)
526 526
      else
527 527
        p_id = p.to_i
......
762 762
    user = new_record? ? author : current_journal.try(:user)
763 763

  
764 764
    required_attribute_names(user).each do |attribute|
765
      if attribute =~ /^\d+$/
765
      if /^\d+$/.match?(attribute)
766 766
        attribute = attribute.to_i
767 767
        v = custom_field_values.detect {|v| v.custom_field_id == attribute }
768 768
        if v && Array(v.value).detect(&:present?).nil?
app/models/mail_handler.rb (working copy)
102 102
      value = email.header[key]
103 103
      if value
104 104
        value = value.to_s.downcase
105
        if (ignored_value.is_a?(Regexp) && value.match(ignored_value)) || value == ignored_value
105
        if (ignored_value.is_a?(Regexp) && ignored_value.match?(value)) || value == ignored_value
106 106
          if logger
107 107
            logger.info "MailHandler: ignoring email with #{key}:#{value} header"
108 108
          end
......
315 315
      else
316 316
        regexp = %r{\A#{Regexp.escape(pattern).gsub("\\*", ".*")}\z}i
317 317
      end
318
      if attachment.filename.to_s =~ regexp
318
      if regexp.match?(attachment.filename.to_s)
319 319
        logger.info "MailHandler: ignoring attachment #{attachment.filename} matching #{pattern}"
320 320
        return false
321 321
      end
app/models/principal.rb (working copy)
174 174
    principal ||= principals.detect {|a| keyword.casecmp(a.login.to_s) == 0}
175 175
    principal ||= principals.detect {|a| keyword.casecmp(a.mail.to_s) == 0}
176 176

  
177
    if principal.nil? && keyword.match(/ /)
177
    if principal.nil? && / /.match?(keyword)
178 178
      firstname, lastname = *(keyword.split) # "First Last Throwaway"
179 179
      principal ||= principals.detect {|a|
180 180
                                 a.is_a?(User) &&
app/models/project.rb (working copy)
311 311
  end
312 312

  
313 313
  def self.find(*args)
314
    if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/)
314
    if args.first && args.first.is_a?(String) && !/^\d*$/.match?(args.first)
315 315
      project = find_by_identifier(*args)
316 316
      raise ActiveRecord::RecordNotFound, "Couldn't find Project with identifier=#{args.first}" if project.nil?
317 317
      project
......
351 351
      nil
352 352
    else
353 353
      # id is used for projects with a numeric identifier (compatibility)
354
      @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier)
354
      @to_param ||= (%r{^\d*$}.match?(identifier.to_s) ? id.to_s : identifier)
355 355
    end
356 356
  end
357 357

  
app/models/query.rb (working copy)
414 414
      if values_for(field)
415 415
        case type_for(field)
416 416
        when :integer
417
          add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(,[+-]?\d+)*\z/) }
417
          add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(,[+-]?\d+)*\z/.match?(v) }
418 418
        when :float
419
          add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/\A[+-]?\d+(\.\d*)?\z/) }
419
          add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/\A[+-]?\d+(\.\d*)?\z/.match?(v) }
420 420
        when :date, :date_past
421 421
          case operator_for(field)
422 422
          when "=", ">=", "<=", "><"
423 423
            add_filter_error(field, :invalid) if values_for(field).detect {|v|
424
              v.present? && (!v.match(/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/) || parse_date(v).nil?)
424
              v.present? && (!/\A\d{4}-\d{2}-\d{2}(T\d{2}((:)?\d{2}){0,2}(Z|\d{2}:?\d{2})?)?\z/.match?(v) || parse_date(v).nil?)
425 425
            }
426 426
          when ">t-", "<t-", "t-", ">t+", "<t+", "t+", "><t+", "><t-"
427
            add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !v.match(/^\d+$/) }
427
            add_filter_error(field, :invalid) if values_for(field).detect {|v| v.present? && !/^\d+$/.match?(v) }
428 428
          end
429 429
        end
430 430
      end
......
1013 1013
      raise "Unknown #{queried_class.name} association #{assoc}" unless customized_class
1014 1014
    end
1015 1015
    where = sql_for_field(field, operator, value, db_table, db_field, true)
1016
    if operator =~ /[<>]/
1016
    if /[<>]/.match?(operator)
1017 1017
      where = "(#{where}) AND #{db_table}.#{db_field} <> ''"
1018 1018
    end
1019 1019
    "#{queried_table_name}.#{customized_key} #{not_in} IN (" +
......
1345 1345

  
1346 1346
  # Returns a Date or Time from the given filter value
1347 1347
  def parse_date(arg)
1348
    if arg.to_s =~ /\A\d{4}-\d{2}-\d{2}T/
1348
    if /\A\d{4}-\d{2}-\d{2}T/.match?(arg.to_s)
1349 1349
      Time.parse(arg) rescue nil
1350 1350
    else
1351 1351
      Date.parse(arg) rescue nil
app/models/repository.rb (working copy)
147 147
  end
148 148

  
149 149
  def self.find_by_identifier_param(param)
150
    if param.to_s =~ /^\d+$/
150
    if /^\d+$/.match?(param.to_s)
151 151
      find_by_id(param)
152 152
    else
153 153
      find_by_identifier(param)
......
246 246
  def find_changeset_by_name(name)
247 247
    return nil if name.blank?
248 248
    s = name.to_s
249
    if s.match(/^\d*$/)
249
    if /^\d*$/.match?(s)
250 250
      changesets.where("revision = ?", s).first
251 251
    else
252 252
      changesets.where("revision LIKE ?", s + '%').first
......
467 467
    regexp = Redmine::Configuration["scm_#{scm_name.to_s.downcase}_path_regexp"]
468 468
    if changes[attribute] && regexp.present?
469 469
      regexp = regexp.to_s.strip.gsub('%project%') {Regexp.escape(project.try(:identifier).to_s)}
470
      unless send(attribute).to_s.match(Regexp.new("\\A#{regexp}\\z"))
470
      unless Regexp.new("\\A#{regexp}\\z").match?(send(attribute).to_s)
471 471
        errors.add(attribute, :invalid)
472 472
      end
473 473
    end
app/models/repository/mercurial.rb (working copy)
96 96
  def find_changeset_by_name(name)
97 97
    return nil if name.blank?
98 98
    s = name.to_s
99
    if /[^\d]/ =~ s or s.size > 8
99
    if /[^\d]/.match?(s) || s.size > 8
100 100
      cs = changesets.where(:scmid => s).first
101 101
    else
102 102
      cs = changesets.where(:revision => s).first
app/models/token.rb (working copy)
110 110
  def self.find_token(action, key, validity_days=nil)
111 111
    action = action.to_s
112 112
    key = key.to_s
113
    return nil unless action.present? && key =~ /\A[a-z0-9]+\z/i
113
    return nil unless action.present? && /\A[a-z0-9]+\z/i.match?(key)
114 114

  
115 115
    token = Token.where(:action => action, :value => key).first
116 116
    if token && (token.action == action) && (token.value == key) && token.user
app/models/workflow_permission.rb (working copy)
62 62
  protected
63 63

  
64 64
  def validate_field_name
65
    unless Tracker::CORE_FIELDS_ALL.include?(field_name) || field_name.to_s.match(/^\d+$/)
65
    unless Tracker::CORE_FIELDS_ALL.include?(field_name) || /^\d+$/.match?(field_name.to_s)
66 66
      errors.add :field_name, :invalid
67 67
    end
68 68
  end
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/database.rb (working copy)
21 21
    class << self
22 22
      # Returns true if the database is PostgreSQL
23 23
      def postgresql?
24
        (ActiveRecord::Base.connection.adapter_name =~ /postgresql/i).present?
24
        /postgresql/i.match?(ActiveRecord::Base.connection.adapter_name)
25 25
      end
26 26

  
27 27
      # Returns the PostgreSQL version or nil if another DBMS is used
......
46 46

  
47 47
      # Returns true if the database is MySQL
48 48
      def mysql?
49
        (ActiveRecord::Base.connection.adapter_name =~ /mysql/i).present?
49
        /mysql/i.match?(ActiveRecord::Base.connection.adapter_name)
50 50
      end
51 51

  
52 52
      # Returns a SQL statement for case/accent (if possible) insensitive match
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/nested_set/project_nested_set.rb (working copy)
119 119

  
120 120
      def lock_nested_set
121 121
        lock = true
122
        if self.class.connection.adapter_name =~ /sqlserver/i
122
        if /sqlserver/i.match?(self.class.connection.adapter_name)
123 123
          lock = "WITH (ROWLOCK HOLDLOCK UPDLOCK)"
124 124
        end
125 125
        self.class.order(:id).lock(lock).ids
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)
184 184

  
185 185
        def target(path, sq=true)
186 186
          path ||= ''
187
          base = path.match(/^\//) ? root_url : url
187
          base = /^\//.match?(path) ? root_url : url
188 188
          str = "#{base}/#{path}".gsub(/[?<>\*]/, '')
189 189
          if sq
190 190
            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.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!(/([\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
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)
(5-5/6)