File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -65,10 +65,10 @@ def initialize(*args)
6565 # If at least one special char is used, string must be quoted
6666
6767 # http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827
68- if matches = /^(['`"])((?!\1 ).)*\1 @([\w %\. :\- ]+)/ . match ( value )
68+ if matches = /^(['`"])((?!\1 ).)*\1 @([\w %\. :\- \/ ]+)$ / . match ( value )
6969 user_part = matches [ 2 ]
7070 host_part = matches [ 3 ]
71- elsif matches = /^([0-9a-zA-Z$_]*)@([\w %\. :\- ]+)/ . match ( value )
71+ elsif matches = /^([0-9a-zA-Z$_]*)@([\w %\. :\- \/ ]+)$ / . match ( value )
7272 user_part = matches [ 1 ]
7373 host_part = matches [ 2 ]
7474 elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/ . match ( value )
@@ -87,6 +87,11 @@ def initialize(*args)
8787 end
8888 end
8989 end
90+
91+ munge do |value |
92+ matches = /^((['`"]?).*\2 )@(.+)$/ . match ( value )
93+ "#{ matches [ 1 ] } @#{ matches [ 3 ] . downcase } "
94+ end
9095 end
9196
9297 newproperty ( :options , :array_matching => :all ) do
Original file line number Diff line number Diff line change 1414 # If at least one special char is used, string must be quoted
1515
1616 # http://stackoverflow.com/questions/8055727/negating-a-backreference-in-regular-expressions/8057827#8057827
17- if matches = /^(['`"])((?:(?!\1 ).)*)\1 @([\w %\. :\- ]+)/ . match ( value )
17+ if matches = /^(['`"])((?:(?!\1 ).)*)\1 @([\w %\. :\- \/ ]+)$ / . match ( value )
1818 user_part = matches [ 2 ]
1919 host_part = matches [ 3 ]
20- elsif matches = /^([0-9a-zA-Z$_]*)@([\w %\. :\- ]+)/ . match ( value )
20+ elsif matches = /^([0-9a-zA-Z$_]*)@([\w %\. :\- \/ ]+)$ / . match ( value )
2121 user_part = matches [ 1 ]
2222 host_part = matches [ 2 ]
2323 elsif matches = /^((?!['`"]).*[^0-9a-zA-Z$_].*)@(.+)$/ . match ( value )
3838 end
3939
4040 munge do |value |
41- matches = /^((['`"]?).*\2 )@([ \w % \. : \- ]+) / . match ( value )
41+ matches = /^((['`"]?).*\2 )@(.+)$ / . match ( value )
4242 "#{ matches [ 1 ] } @#{ matches [ 3 ] . downcase } "
4343 end
4444 end
Original file line number Diff line number Diff line change 5151 end
5252 end
5353
54+ context 'using foo@192.168.1.0/255.255.255.0' do
55+ before :each do
56+ @user = Puppet ::Type . type ( :mysql_user ) . new ( :name => 'foo@192.168.1.0/255.255.255.0' , :password_hash => 'pass' )
57+ end
58+
59+ it 'should create the user with the netmask' do
60+ expect ( @user [ :name ] ) . to eq ( 'foo@192.168.1.0/255.255.255.0' )
61+ end
62+ end
63+
5464 context 'using allo_wed$char@localhost' do
5565 before :each do
5666 @user = Puppet ::Type . type ( :mysql_user ) . new ( :name => 'allo_wed$char@localhost' , :password_hash => 'pass' )
You can’t perform that action at this time.
0 commit comments