Subject: Parsing iCalendar

From: Joshua Ostrowalker <[email-masked]>
Date: Fri, 21 May 1999 13:47:16 -0400

Hi everyone,

I have come across a problem when parsing properties in iCalendar (and
it affects vCard as well) and was wondering if anyone else has come
across the same sort of thing.

There is well-defined behaviour when processing the ',', ';', and ':'
characters... they either have to be escaped, or placed within a
quoted-text value.  However, there is no specification for dealing with
the '"' and '=' characters.

With the '"' character, the parser would assume the following characters
to be a quoted-text value, however, there are certainly cases where the
'"' character would be inside the value.  This really becomes a problem
if there are an odd number of '"' characters in the value string.

The problem with the '=' character is that it is used by the parser to
create name-value pairs (eg. "TYPE=TEL").  This isn't a problem in
property parameters in which the first '=' will always be used for this
purpose and all following ones can be assumed as part of the value. 
However, in iCalendar there are '=' characters used for this purpose in
the property value.  Eg. in the RRULE and EXRULE.  Other property values
can just be a text-value containing the '=' character.  Without creating
a special case for properties that might use the '=' character as a
token, we have a problem discerning the two.

Both of these problems could easily be taken care of, if the '"' and '='
characters had to always be escaped when used in a value.  I am curious
about other solutions people have devised.

If this question has already been asked, I apologize and would ask that
someone direct me to the information.

Thanks,

Joshua.

---

From: Frank Dawson/CAM/Lotus <[email-masked]>
Date: Mon, 24 May 1999 17:52:53 GMT

Joshua Ostrowalker wrote, in part:

>My parser design does extract the property name, property parameters,
>and property value.  However, in an attempt to keep the parser small and
>efficient, it has no concept of the context of the properties.  In other
>words, it does not understand or recognize the particular properties and
>what valid parameters/values can be used with that property.  Data
>validation is done by the objects using the resultant data structures.
>As a result, the parser has no way of knowing that because the current
>property being parsed is "RRULE" that the '=' characters in the property
>value are significant.  Whereas with another property, the character
>would just be part of the value.
>
>I will be surprised if no one else has attempted to create a lightweight
>parser like this.  In any case, I will have to work something out to
>overcome this problem.

<fd>You may want to look at the ABNF for both of these. I believe that the
set of valid property parameters is property specific. In addition, the
property value is also dependent on the property parameters. Hence, you
need a multistep parser. This doesn't mean you can't have a lightweight
parser. Indeed, a terse parser can be written for this syntax.</fd>