Skip to content

Commit

Permalink
Merge branch 'seebq-qp'
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-github committed Feb 11, 2010
2 parents 2c6267e + da925b3 commit fb3ff89
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
34 changes: 19 additions & 15 deletions lib/vpim/rfc2425.rb
Expand Up @@ -76,22 +76,26 @@ module Vpim
# This also supports the (invalid) encoding convention of allowing empty
# lines to be inserted for readability - it does this by dropping zero-length
# lines.
def Vpim.unfold(card) #:nodoc:
unfolded = []

card.each_line do |line|
line.chomp!
# If it's a continuation line, add it to the last.
# If it's an empty line, drop it from the input.
if( line =~ /^[ \t]/ )
unfolded[-1] << line[1, line.size-1]
elsif( line =~ /^$/ )
else
unfolded << line
end
#
# Also supports an the QUOTED-PRINTABLE soft line-break as described here:
# http://en.wikipedia.org/wiki/Quoted-printable
#
def Vpim.unfold(card) # :nodoc:
unfolded = []
card.each do |line|
line.chomp!
# If it's a continuation line, add it to the last.
# If it's an empty line, drop it from the input.
if( line =~ /^[ \t]/ )
unfolded[-1] << line[1, line.size-1]
elsif (unfolded.last && unfolded.last =~ /;ENCODING=QUOTED-PRINTABLE:.*?=$/)
unfolded.last << line
elsif( line =~ /^$/ )
else
unfolded << line
end

unfolded
end
unfolded
end

# Convert a +sep+-seperated list of values into an array of values.
Expand Down
22 changes: 22 additions & 0 deletions test/test_vcard.rb
Expand Up @@ -918,6 +918,28 @@ def test_highrises_invalid_google_talk_field

end

def test_quoted_printable
c = <<'__'
BEGIN:VCARD
VERSION:2.1
N:Quinn;Charles
FN:Charles Quinn
NOTE;ENCODING=QUOTED-PRINTABLE: =0D=0Acbq+highgroove@example.com <mailto:cbq+highgroove@example.com>=0D=0A555-555-2=
500 - Office=0D=0A555-555-2502 - Fax
TEL;WORK;VOICE:555 555 2500
TEL;WORK;FAX:555 555 2502
EMAIL;PREF;INTERNET:cbq+highgroove@example.com
REV:20100210T201157Z
END:VCARD
__
card = Vpim::Vcard.decode(c).first
assert_equal("Quinn", card.name.family)
assert_equal(
"=0D=0Acbq+highgroove@example.com <mailto:cbq+highgroove@example.com>=0D=0A555-555-2=500 - Office=0D=0A555-555-2502 - Fax",
card.note
)
end

def _test_gmail_vcard_export
# GOOGLE BUG - Whitespace before the LABEL field values is a broken
# line continuation.
Expand Down

0 comments on commit fb3ff89

Please sign in to comment.