diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 2c0b7635a..07348cd61 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -541,7 +541,7 @@ class Attachment < ApplicationRecord just_filename = value.gsub(/\A.*(\\|\/)/m, '') # Finally, replace invalid characters with underscore - just_filename.gsub(/[\/\?\%\*\:\|\"\'<>\n\r]+/, '_') + just_filename.gsub(/[\/?%*:|"'<>\n\r]+/, '_') end # Returns the subdirectory in which the attachment will be saved @@ -556,7 +556,7 @@ class Attachment < ApplicationRecord def create_diskfile(filename, directory=nil, &) timestamp = DateTime.now.strftime("%y%m%d%H%M%S") ascii = '' - if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50 + if %r{^[a-zA-Z0-9_.-]*$}.match?(filename) && filename.length <= 50 ascii = filename else ascii = ActiveSupport::Digest.hexdigest(filename) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 40e6cf51c..a9838fd11 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -117,7 +117,7 @@ class Changeset < ApplicationRecord | (\d+):(\d+) | - (\d+([\.,]\d+)?)h? + (\d+([.,]\d+)?)h? ) /x @@ -135,7 +135,7 @@ class Changeset < ApplicationRecord referenced_issues = [] regexp = %r{ - ([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)? + ([\s(\[,-]|^)((#{kw_regexp})[\s:]+)? (\#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+\#\d+(\s+@#{TIMELOG_RE})?)*) (?=[[:punct:]]|\s|<|$) }xi diff --git a/app/models/user.rb b/app/models/user.rb index f41f654e1..124755775 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,7 +122,7 @@ class User < Principal validates_presence_of :login, :firstname, :lastname, :if => Proc.new {|user| !user.is_a?(AnonymousUser)} validates_uniqueness_of :login, :if => Proc.new {|user| user.login_changed? && user.login.present?}, :case_sensitive => false # Login must contain letters, numbers, underscores only - validates_format_of :login, :with => /\A[a-z0-9_\-@\.]*\z/i + validates_format_of :login, :with => /\A[a-z0-9_\-@.]*\z/i validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT validates_length_of :firstname, :maximum => 30 validates_length_of :lastname, :maximum => 255 diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index d76e288d8..3b638085d 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -52,7 +52,7 @@ class WikiPage < ApplicationRecord attr_writer :deleted_attachment_ids validates_presence_of :title - validates_format_of :title, :with => /\A[^,\.\/\?\;\|\s]*\z/ + validates_format_of :title, :with => /\A[^,.\/?;|\s]*\z/ validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false validates_length_of :title, maximum: 255 validates_associated :content diff --git a/config/routes.rb b/config/routes.rb index df48e19e9..75e7ea01c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -297,7 +297,7 @@ Rails.application.routes.draw do :controller => 'repositories', :action => action, :format => 'html', - :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/} + :constraints => {:rev => /[a-z0-9.\-_]+/, :path => /.*/} end %w(browse entry raw changes annotate).each do |action| @@ -311,7 +311,7 @@ Rails.application.routes.draw do get "projects/:id/repository/:repository_id/revisions/:rev/diff(/*path)", :to => 'repositories#diff', :format => 'html', - :constraints => {:rev => /[a-z0-9\.\-_]+/, :path => /.*/, :format => /(html|diff)/ } + :constraints => {:rev => /[a-z0-9.\-_]+/, :path => /.*/, :format => /(html|diff)/ } get "projects/:id/repository/:repository_id/diff(/*path)", :to => 'repositories#diff', diff --git a/lib/redmine/scm/adapters/cvs_adapter.rb b/lib/redmine/scm/adapters/cvs_adapter.rb index 07e882826..50788dab1 100644 --- a/lib/redmine/scm/adapters/cvs_adapter.rb +++ b/lib/redmine/scm/adapters/cvs_adapter.rb @@ -317,7 +317,7 @@ module Redmine blame = Annotate.new scm_cmd(*cmd_args) do |io| io.each_line do |line| - next unless line =~ %r{^([\d\.]+)\s+\(([^\)]+)\s+[^\)]+\):\s(.*)$} + next unless line =~ %r{^([\d.]+)\s+\(([^)]+)\s+[^)]+\):\s(.*)$} blame.add_line( $3.rstrip, diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index c7a5c6b66..28c2f7496 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -118,7 +118,7 @@ module Redmine end def entry(path=nil, identifier=nil) - parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?} + parts = path.to_s.split(%r{[/\\]}).select {|n| !n.blank?} search_path = parts[0..-2].join('/') search_name = parts[-1] if search_path.blank? && search_name.blank? diff --git a/lib/redmine/scm/adapters/subversion_adapter.rb b/lib/redmine/scm/adapters/subversion_adapter.rb index c4bb31148..4183f53ca 100644 --- a/lib/redmine/scm/adapters/subversion_adapter.rb +++ b/lib/redmine/scm/adapters/subversion_adapter.rb @@ -302,7 +302,7 @@ module Redmine base = path.start_with?('/') ? root_url : url uri = "#{base}/#{path}" uri = Addressable::URI.encode(uri) - shell_quote(uri.gsub(/[?<>\*]/, '')) + shell_quote(uri.gsub(/[?<>*]/, '')) end end end