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

Handle newlines within fields #71

Open
ManolisKoufidakis opened this issue Sep 24, 2024 · 2 comments
Open

Handle newlines within fields #71

ManolisKoufidakis opened this issue Sep 24, 2024 · 2 comments

Comments

@ManolisKoufidakis
Copy link

ManolisKoufidakis commented Sep 24, 2024

Hi,
The code throws exception when parsing some vcards (like the one below) where there is a newline character within a field.

The exception is:

Error while reading vcard qr. Error: System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
   at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
   at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName)
   at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at vCardLib.Deserialization.FieldDeserializers.CustomFieldDeserializer.Read(String input)
   at vCardLib.Deserialization.vCardDeserializer.DeserializeV3(IReadOnlyCollection`1 vcardContent)
   at vCardLib.Deserialization.vCardDeserializer.Convert(String[] vcardContent)
   at vCardLib.Deserialization.vCardDeserializer.FromContent(String vcardContents)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

A sample vcard is:

BEGIN:VCARD
VERSION:2.1
N:Test;Tester
FN:Tester Test
ORG:ACME India PVT LTD
TITLE:Technical Sales & Support 
South India
TEL;CELL:+91 22222 22222
TEL;WORK;VOICE:+91 222 22222222
ADR;WORK:;;J 123, ASD;Delhi;Bhosari;411026.;India
EMAIL;WORK;INTERNET:[email protected]
URL:www.acme.com
END:VCARD
@bolorundurowb
Copy link
Owner

I'll check the RFC to see if rows are allowed to wrap, my understanding is that they are supposed to be escaped and quoted. Something like TITLE:"Technical Sales & Support \nSouth India"

@henrihein
Copy link

https://www.rfc-editor.org/rfc/rfc6350#section-3.2
Lines after a line-break that is part of the same field should start with whitespace (space or tab).

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

3 participants