Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-idempotent or erroneous newlines in 0.0.2 #3

Open
k3rni opened this issue May 7, 2013 · 0 comments
Open

Non-idempotent or erroneous newlines in 0.0.2 #3

k3rni opened this issue May 7, 2013 · 0 comments

Comments

@k3rni
Copy link

k3rni commented May 7, 2013

Let's take a sample card from Wikipedia on vCard:

BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;TYPE=WORK:100 Waters Edge\nBaytown, LA 30314\nUnited States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;TYPE=HOME:42 Plantation St.\nBaytown, LA 30314\nUnited States of America
EMAIL;TYPE=PREF,INTERNET:[email protected]
REV:2008-04-24T19:52:43Z
END:VCARD

It loads fine:

1.9.3-p385 :152 > VCardigan.parse card3
 => BEGIN:VCARD
VERSION:3.0
N:Gump;Forrest;;;
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;VALUE=URL;TYPE=GIF:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=WORK,VOICE:(111) 555-1212
TEL;TYPE=HOME,VOICE:(404) 555-1212
ADR;TYPE=WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
ADR;TYPE=HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America

LABEL;TYPE=WORK:100 Waters Edge
LABEL;TYPE=HOME:42 Plantation St.
BAYTOWN, LA 30314:Baytown, LA 30314
BAYTOWN, LA 30314:Baytown, LA 30314
UNITED STATES OF AMERICA:United States of America
UNITED STATES OF AMERICA:United States of America
EMAIL;TYPE=PREF,INTERNET:forrestgump@example.com
REV:2008-04-24T19:52:43Z
END:VCARD

(Note the extra newline between ADR and LABEL). But when we serialize it back to vcard and try loading:

1.9.3-p385 :154 > VCardigan.parse VCardigan.parse(card3).to_s
NoMethodError: undefined method `split' for nil:NilClass
    from /usr/local/rvm/gems/ruby-1.9.3-p385/gems/vcardigan-0.0.2/lib/vcardigan/property.rb:67:in `parse'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/gems/vcardigan-0.0.2/lib/vcardigan/vcard.rb:34:in `block in parse'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/gems/vcardigan-0.0.2/lib/vcardigan/vcard.rb:33:in `each_line'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/gems/vcardigan-0.0.2/lib/vcardigan/vcard.rb:33:in `parse'
    from /usr/local/rvm/gems/ruby-1.9.3-p385/gems/vcardigan-0.0.2/lib/vcardigan.rb:16:in `parse'
    from (irb):154
    from /usr/local/rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `<main>'

Loads fine once we remove that newline

1.9.3-p385 :156 > VCardigan.parse VCardigan.parse(card3).to_s.gsub("\n \n", "\n")
# output omitted, no exceptions raised
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant