Skip to content

Commit 95314f0

Browse files
authored
https://github.com/sam-github/vpim/pull/20
1 parent 5002482 commit 95314f0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/vpim/rfc2425.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,21 @@ def Vpim.decode_text_list(value, sep = ',') # :nodoc:
290290
# paramtext = *SAFE-CHAR
291291
# quoted-string = DQUOTE *QSAFE-CHAR DQUOTE
292292
def Vpim.encode_paramtext(value)
293-
case value
294-
when %r{\A#{Bnf::SAFECHAR}*\z}
293+
bin_value = value.dup.force_encoding('ASCII-8BIT')
294+
case bin_value
295+
when %r{\A#{Bnf::SAFECHAR}*\z}n
295296
value
296297
else
297298
raise Vpim::Unencodeable, "paramtext #{value.inspect}"
298299
end
299300
end
300301

301-
def Vpim.encode_paramvalue(value)
302-
case value
303-
when %r{\A#{Bnf::SAFECHAR}*\z}
302+
def Vpim.encode_paramvalue(value)
303+
bin_value = value.dup.force_encoding('ASCII-8BIT')
304+
case bin_value
305+
when %r{\A#{Bnf::SAFECHAR}*\z}n
304306
value
305-
when %r{\A#{Bnf::QSAFECHAR}*\z}
307+
when %r{\A#{Bnf::QSAFECHAR}*\z}n
306308
'"' + value + '"'
307309
else
308310
raise Vpim::Unencodeable, "param-value #{value.inspect}"

0 commit comments

Comments
 (0)