Skip to content

Commit

Permalink
https://github.com/sam-github/vpim/pull/20
Browse files Browse the repository at this point in the history
  • Loading branch information
whitebearded authored Feb 27, 2018
1 parent 5002482 commit 95314f0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/vpim/rfc2425.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 95314f0

Please sign in to comment.