1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-01 03:57:15 +00:00

Fix RuboCop Style/RedundantRegexpEscape (#43437).

git-svn-id: https://svn.redmine.org/redmine/trunk@24120 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2025-11-05 06:56:50 +00:00
parent 8a6ef6ddbc
commit 48a0e9ade2
8 changed files with 11 additions and 11 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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',

View File

@ -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,

View File

@ -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?

View File

@ -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