Project

General

Profile

Defect #43521 ยป cf-regexp-error.patch

Go MAEDA, 2025-11-25 04:46

View differences:

lib/redmine/field_format.rb
381 381
      def validate_single_value(custom_field, value, customized=nil)
382 382
        errs = super
383 383
        value = value.to_s
384
        unless custom_field.regexp.blank? or Regexp.new(custom_field.regexp).match?(value)
385
          errs << ::I18n.t('activerecord.errors.messages.invalid')
384
        if custom_field.regexp.present?
385
          begin
386
            unless Regexp.new(custom_field.regexp).match?(value)
387
              errs << ::I18n.t('activerecord.errors.messages.invalid')
388
            end
389
          rescue RegexpError
390
            # The invalid regexp is validated in CustomField#validate_custom_field,
391
            # so we can skip validation here
392
          end
386 393
        end
387 394
        if custom_field.min_length && value.length < custom_field.min_length
388 395
          errs << ::I18n.t('activerecord.errors.messages.too_short', :count => custom_field.min_length)
    (1-1/1)