From 95314f00330af489519cb36f371ffe422c3792e1 Mon Sep 17 00:00:00 2001 From: Student92 Date: Tue, 27 Feb 2018 08:08:23 +0100 Subject: [PATCH] https://github.com/sam-github/vpim/pull/20 --- lib/vpim/rfc2425.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/vpim/rfc2425.rb b/lib/vpim/rfc2425.rb index f2a6150..8e5b193 100644 --- a/lib/vpim/rfc2425.rb +++ b/lib/vpim/rfc2425.rb @@ -290,19 +290,21 @@ def Vpim.decode_text_list(value, sep = ',') # :nodoc: # paramtext = *SAFE-CHAR # quoted-string = DQUOTE *QSAFE-CHAR DQUOTE def Vpim.encode_paramtext(value) - case value - when %r{\A#{Bnf::SAFECHAR}*\z} + bin_value = value.dup.force_encoding('ASCII-8BIT') + case bin_value + when %r{\A#{Bnf::SAFECHAR}*\z}n value else raise Vpim::Unencodeable, "paramtext #{value.inspect}" end end - def Vpim.encode_paramvalue(value) - case value - when %r{\A#{Bnf::SAFECHAR}*\z} + def Vpim.encode_paramvalue(value) + bin_value = value.dup.force_encoding('ASCII-8BIT') + case bin_value + when %r{\A#{Bnf::SAFECHAR}*\z}n value - when %r{\A#{Bnf::QSAFECHAR}*\z} + when %r{\A#{Bnf::QSAFECHAR}*\z}n '"' + value + '"' else raise Vpim::Unencodeable, "param-value #{value.inspect}"