mangstadt / ez-vcard

A vCard parser library for Java
Other
399 stars 92 forks source link

Folded line whitespace differs across versions #59

Closed mangstadt closed 8 years ago

mangstadt commented 8 years ago

Versions 3.0 and 4.0 state that all folded lines must begin with exactly one whitespace character. However, version 2.1 states that a folded line can begin with one or more whitespace characters.

ez-vcard currently only ignores the first whitespace character when parsing folded lines. Therefore, if a 2.1 vCard prepends folded lines with multiple whitespace characters, ez-vcard will treat the extra whitespace characters as part of the value. This wrong.

Therefore, when parsing a 2.1 vCard, ez-vcard should ignore ALL whitespace characters at the beginning of each folded line (not just the first whitespace character, as is currently done).

In addition, when writing a 2.1 vCard, ez-vcard should take care to fold long lines in such a way so that none of the folded lines begin with whitespace characters that are part of the property value.

Note: Fixing this issue will probably mean that the code in the BinaryPropertyScribe that removes whitespace characters from base64 values can be removed. This code was added because one of the sample vCards used in unit testing is a 2.1 vCard that uses multiple whitespace characters for folding (I didn't know at the time that 2.1 allows multiple whitespace characters).

mangstadt commented 8 years ago

Fixed in 92409572925ec7be47ebc658ed53bb137ee51bcd.