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

Unfold vCard before parsing #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andy-bower
Copy link
Contributor

Closes #38 by unfolding vCard as per RFC before parsing it. This makes mcds usable for convenient command line queries of postal addresses which would otherwise be truncated.

This pipelined approach seems to be a simpler solution than building continuation handing into the main parser. There are other ways in which the parse could be enhanced but it would probably still be easier to do the unfolding as a separate step, like this.

Example:

BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 4.5.4//EN
UID:95d439db-4c43-47d3-99d8-ca286c61a2aa
FN:Test Contact
ADR;TYPE=HOME:A very long address;Requiring multiple continuation lines;Tak
 ing several lines and;In a very very big city somewhere;in a huge ginormou
 s province;DSFH324324HFDSH 43432;of the land over the water\, up in the sk
 y and milions of light years away
END:VCARD

Unfolding cut 9 bytes
Regex for query term: ^FN([A-Za-z;=])*:(.*test.*)
Regex for search term: ADR(.*):(.*)
A very long address;Requiring multiple continuation lines;Taking several lines and;In a very very big city somewhere;in a huge ginormous province;DSFH324324HFDSH 43432;of the land over the water\, up in the sky and milions of light years away	Test Contact

Moves regular expression compilation out into a wrapper function that
handles errors, so that we can add additional regular expression usage
without exploding the code.
Follow the RFC by unfolding folded vCard lines (CRLF WSP) before using
the vCard. This is done in place as we will be accessing all the data
immediately anyway as we pass the automata over it so it is likely to
stay in cache.

This pipelined approach seems easier than special handling of
continuation lines and follows the spirit of the specification.
/**
* Compile regex, checking and handling errors.
*
* \parm[in] preg The compiled regex.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the doxygen should be out, not in for this parameter!
By the way, have you ever attempted a doxygen run over this source? I haven't!

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

Successfully merging this pull request may close these issues.

vCard continuation lines ignored
1 participant