summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-22 15:37:04 -0800
committerJesse Wolfe <jes5199@gmail.com>2010-11-22 15:37:04 -0800
commit3d2fbf604f997e6b9fd94edb96419ffa9869e709 (patch)
treec5a082ba09fd90d100f6cd16602aae4c21d36ea6 /lib/puppet
parent9914140377a82b6c2de45685f565b2607d8b8364 (diff)
parent095675711a89d836f4d0f10978ed5759b93fe76f (diff)
downloadpuppet-3d2fbf604f997e6b9fd94edb96419ffa9869e709.tar.gz
puppet-3d2fbf604f997e6b9fd94edb96419ffa9869e709.tar.xz
puppet-3d2fbf604f997e6b9fd94edb96419ffa9869e709.zip
Merge branch 'ticket/2.6.x/5261' into next
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/external/pson/pure/generator.rb23
1 files changed, 1 insertions, 22 deletions
diff --git a/lib/puppet/external/pson/pure/generator.rb b/lib/puppet/external/pson/pure/generator.rb
index 4180be57d..89a0c62e0 100644
--- a/lib/puppet/external/pson/pure/generator.rb
+++ b/lib/puppet/external/pson/pure/generator.rb
@@ -44,34 +44,13 @@ module PSON
string << '' # XXX workaround: avoid buffer sharing
string.force_encoding(Encoding::ASCII_8BIT)
string.gsub!(/["\\\x0-\x1f]/) { MAP[$MATCH] }
- string.gsub!(/(
- (?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+ |
- [\x80-\xc1\xf5-\xff] # invalid
- )/nx) { |c|
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- s = PSON::UTF8toUTF16.iconv(c).unpack('H*')[0]
- s.gsub!(/.{4}/n, '\\\\u\&')
- }
- string.force_encoding(Encoding::UTF_8)
string
rescue Iconv::Failure => e
raise GeneratorError, "Caught #{e.class}: #{e}"
end
else
def utf8_to_pson(string) # :nodoc:
- string.
- gsub(/["\\\x0-\x1f]/n) { MAP[$MATCH] }.
- gsub(/((?:
- [\xc2-\xdf][\x80-\xbf] |
- [\xe0-\xef][\x80-\xbf]{2} |
- [\xf0-\xf4][\x80-\xbf]{3}
- )+)/nx) { |c|
- PSON::UTF8toUTF16.iconv(c).unpack('H*')[0].gsub(/.{4}/n, '\\\\u\&')
- }
+ string.gsub(/["\\\x0-\x1f]/n) { MAP[$MATCH] }
end
end
module_function :utf8_to_pson