From: Daniele Sluijters Date: Thu, 26 Jun 2014 12:26:02 +0000 (+0200) Subject: MODULES-780 Don't blow up on unicode characters. X-Git-Tag: 1.6.0~19^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=14b3beda74999aefc4cd02f681321e7797c1ef2f;p=puppet-modules%2Fpuppetlabs-apt.git MODULES-780 Don't blow up on unicode characters. Gotta love the difference between Ruby 1.8.7 not caring and every subsequent version exploding. --- diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index f8d4072..1d3c174 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -26,6 +26,11 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do commands :apt_key => 'apt-key' def self.instances + if RUBY_VERSION > '1.8.7' + key_output = apt_key('list').encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '') + else + key_output = apt_key('list') + end key_array = apt_key('list').split("\n").collect do |line| line_hash = key_line_hash(line) next unless line_hash