Skip to content

Commit

Permalink
Fix issues introduced in puppetlabs/puppetlabs-mysql#612
Browse files Browse the repository at this point in the history
The regex updates caused failures in some places where it previously
(correctly) worked.
  • Loading branch information
Morgan Haskel committed Dec 13, 2014
1 parent 2f9820c commit a611686
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/puppet/type/mysql_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def initialize(*args)
# If at least one special char is used, string must be quoted

# http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827
if matches = /^(['`"])((?!\1).)+\1@([\w%\.:]+)$/.match(value)
if matches = /^(['`"])((?!\1).)*\1@([\w%\.:\-]+)/.match(value)
user_part = matches[2]
host_part = matches[3]
elsif matches = /^([0-9a-zA-Z$_]+)@([\w%\.:]+)$/.match(value)
elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-]+)/.match(value)
user_part = matches[1]
host_part = matches[2]
elsif matches = /^(?:(?!['`"]).*)([^0-9a-zA-Z$_]).*@.+$/.match(value)
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/type/mysql_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# If at least one special char is used, string must be quoted

# http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827
if matches = /^(['`"])((?:(?!\1).)+)\1@([\w%\.:]+)$/.match(value)
if matches = /^(['`"])((?:(?!\1).)*)\1@([\w%\.:\-]+)/.match(value)
user_part = matches[2]
host_part = matches[3]
elsif matches = /^([0-9a-zA-Z$_]+)@([\w%\.:]+)$/.match(value)
elsif matches = /^([0-9a-zA-Z$_]*)@([\w%\.:\-]+)/.match(value)
user_part = matches[1]
host_part = matches[2]
elsif matches = /^(?:(?!['`"]).*)([^0-9a-zA-Z$_]).*@.+$/.match(value)
Expand All @@ -30,7 +30,7 @@
end

munge do |value|
matches = /^((['`"]?).+\2)@([\w%\.:]+)$/.match(value)
matches = /^((['`"]?).*\2)@([\w%\.:\-]+)/.match(value)
"#{matches[1]}@#{matches[3].downcase}"
end
end
Expand Down

0 comments on commit a611686

Please sign in to comment.