From a611686530414d0c80375c19f007052e356aefe6 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Fri, 12 Dec 2014 17:36:46 -0800 Subject: [PATCH] Fix issues introduced in puppetlabs/puppetlabs-mysql#612 The regex updates caused failures in some places where it previously (correctly) worked. --- lib/puppet/type/mysql_grant.rb | 4 ++-- lib/puppet/type/mysql_user.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/puppet/type/mysql_grant.rb b/lib/puppet/type/mysql_grant.rb index d6e354345..4c49ff857 100644 --- a/lib/puppet/type/mysql_grant.rb +++ b/lib/puppet/type/mysql_grant.rb @@ -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) diff --git a/lib/puppet/type/mysql_user.rb b/lib/puppet/type/mysql_user.rb index 271baac24..55a7a3404 100644 --- a/lib/puppet/type/mysql_user.rb +++ b/lib/puppet/type/mysql_user.rb @@ -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) @@ -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