Opened 2 years ago

Closed 22 months ago

#1487873 closed Bugs (fixed)

vCard folding issues

Reported by: alec Owned by: thomasb
Priority: 5 Milestone: 0.6-beta
Component: Addressbook Version: 0.5.1
Severity: normal Keywords:
Cc:

Description

I see few more issues related to our folding method. See

return preg_replace_callback('/:([^\n]{72,})/', array('self', 'rfc2425_fold_callback'), $val) . "\n";
  1. This part is not unicode-aware. Can fold line (with many multibyte characters) when it's not required (because the regexp counts bytes not characters).
  2. It doesn't handle situation when long line contains escaped ":" character.
  3. Folding should take the whole line into consideration. In our code only the length of the string on the right of ":" character is calculated.

That's why I think we should move folding procedure into vcard_encode() method, where we could handle all of these issues.

Change History (7)

comment:1 Changed 2 years ago by koessler

Pls be aware that your implementation is not RFC2426/RFC2425 compliant. There it says clearly: "CRLF immediately followed by a single white space character". Your implementation inserts a LF immediately followed by 2 white space characters.

comment:2 Changed 2 years ago by thomasb

  • Owner set to thomasb
  • Status changed from new to assigned

OK, redo from scratch :-)

comment:3 Changed 2 years ago by alec

Just a hint. In Mail_mime I used mb_substr/mb_strlen for similiar task. Maybe it would be better instead of mb_ereg*.

comment:4 follow-up: Changed 2 years ago by thomasb

  1. IMO counting should be done on chars (bytes) and not on unicode characters. Therefore I think this check is correct.
  2. and 3. Should be fixed in [569f8306] Also folding is now skipped for internal storage since it doesn't make a difference and it only takes processing time for nothing.

Still I cannot import vcards with folded photos into my Mac Address Book. Only unfolded files work correctly.

comment:5 in reply to: ↑ 4 Changed 2 years ago by alec

Replying to thomasb:

  1. IMO counting should be done on chars (bytes) and not on unicode characters. Therefore I think this check is correct.

I wouldn't be so sure about that. RFC2425 is talking about characters. In other places it says that default encoding is 8bit and also points to UTF-8.

comment:6 Changed 22 months ago by alec

As someone stated on the mailing list we should use CRLF for the whole vcard, not only for folded lines. Maybe this will fix your Mac issue?

comment:7 Changed 22 months ago by alec

  • Resolution set to fixed
  • Status changed from assigned to closed

I've fixed EOL in [359e19a1]. I think the ticket can be closed now.

Note: See TracTickets for help on using tickets.