From 71cb0f4c2c3bf95f62c9f189f5cef155b09a9682 Mon Sep 17 00:00:00 2001 From: varac Date: Wed, 30 Oct 2013 22:20:48 +0100 Subject: obfuscate_email(): allow multiple email addresses see https://leap.se/code/issues/4193 for more information --- lib/puppet/parser/functions/obfuscate_email.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/puppet/parser/functions/obfuscate_email.rb b/lib/puppet/parser/functions/obfuscate_email.rb index 07ccf72..4e4cb82 100644 --- a/lib/puppet/parser/functions/obfuscate_email.rb +++ b/lib/puppet/parser/functions/obfuscate_email.rb @@ -1,17 +1,15 @@ module Puppet::Parser::Functions newfunction(:obfuscate_email, :type => :rvalue, :doc => <<-EOS Given: - an email in form of john@doe.com + a comma seperated email string in form of 'john@doe.com, doe@john.com' -This function will return an obfuscated email in form of 'john {at} doe {dot} com' +This function will return all emails obfuscated in form of 'john {at} doe {dot} com, doe {at} john {dot} com' +Works with multiple email adresses as well as with a single email adress. EOS ) do |args| - email=args[0] - email["@"]= " {at} " - email=email.gsub(/(.*)(\.)(.*)/, '\1 {dot} \3') - email - end + args[0].gsub('@', ' {at} ').gsub('.', ' {dot} ') + end end # vim: set ts=2 sw=2 et : -- cgit v1.2.3