Skip to content

(MODULES-5602) remove superfluous backslashes from regular expressions #989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/type/mysql_datadir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

newparam(:defaults_extra_file) do
desc 'MySQL defaults-extra-file with absolute path (*.cnf).'
newvalues(%r{^\/.*\.cnf$})
newvalues(%r{^/.*\.cnf$})
end

newparam(:insecure, boolean: true) do
Expand All @@ -29,6 +29,6 @@

newparam(:log_error) do
desc 'The path to the mysqld error log file (used with the --log-error option)'
newvalues(%r{^\/})
newvalues(%r{^/})
end
end
8 changes: 4 additions & 4 deletions lib/puppet/type/mysql_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def initialize(*args)
desc 'Table to apply privileges to.'

validate do |value|
raise(ArgumentError, '"table" for PROXY should be specified as proxy_user@proxy_host') if Array(@resource[:privileges]).include?('PROXY') && !%r{^[0-9a-zA-Z$_]*@[\w%\.:\-\/]*$}.match(value)
raise(ArgumentError, '"table" for PROXY should be specified as proxy_user@proxy_host') if Array(@resource[:privileges]).include?('PROXY') && !%r{^[0-9a-zA-Z$_]*@[\w%\.:\-/]*$}.match(value)
end

munge do |value|
value.delete('`')
end

newvalues(%r{.*\..*}, %r{^[0-9a-zA-Z$_]*@[\w%\.:\-\/]*$})
newvalues(%r{.*\..*}, %r{^[0-9a-zA-Z$_]*@[\w%\.:\-/]*$})
end

newproperty(:user) do
Expand All @@ -81,10 +81,10 @@ def initialize(*args)
# http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827
# rubocop:disable Lint/AssignmentInCondition
# rubocop:disable Lint/UselessAssignment
if matches = %r{^(['`"])((?!\1).)*\1@([\w%\.:\-\/]+)$}.match(value)
if matches = %r{^(['`"])((?!\1).)*\1@([\w%\.:\-/]+)$}.match(value)
user_part = matches[2]
host_part = matches[3]
elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$}.match(value)
elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-/]+)$}.match(value)
user_part = matches[1]
host_part = matches[2]
elsif matches = %r{^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$}.match(value)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/type/mysql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
mysql_version = Facter.value(:mysql_version)
# rubocop:disable Lint/AssignmentInCondition
# rubocop:disable Lint/UselessAssignment
if matches = %r{^(['`"])((?:(?!\1).)*)\1@([\w%\.:\-\/]+)$}.match(value)
if matches = %r{^(['`"])((?:(?!\1).)*)\1@([\w%\.:\-/]+)$}.match(value)
user_part = matches[2]
host_part = matches[3]
elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-\/]+)$}.match(value)
elsif matches = %r{^([0-9a-zA-Z$_]*)@([\w%\.:\-/]+)$}.match(value)
user_part = matches[1]
host_part = matches[2]
elsif matches = %r{^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$}.match(value)
Expand Down