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

Remove node-ical module and use simple parser #267 #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NeilRashbrook
Copy link
Collaborator

The parsing part is reasonably straightforward.

The parsing part is reasonably straightforward.
@benbucksch
Copy link
Collaborator

benbucksch commented Jan 23, 2025

Did you check with the spec (RFC) that you capture all escaping and quoting? Including the interaction between escaping and quoting?

Please answer with more than "Yes", but show where in the spec it is defined, and where you implement it. If it doesn't exist in the spec, please show the closest part of the spec. If my memory serves me right and both escaping and quoting exists, please also show based on spec and code that you implement that interaction between them correctly.

@NeilRashbrook
Copy link
Collaborator Author

There are two relevant data types here. The first is the text type, defined in RFC 5545 section 3.3.11, which is not quoted, but does have five escapes \n, \N, \;, \, and \\. The second is the param-value type, defined in RFC 5545 section 3.1, which may be quoted. No escapes are defined for this type, instead :, ; and , characters should only be included by quoting. (But see below.)

  • Unescaping is handled by unescaped. It only special-cases \n and \N, and just removes any other unpaired nontrailing \s. (Paired \\s become single \s of course.)
  • Unquoting is handled by the constructor of class icalEntry. If the character after the = is a quote, the regex looks for a matching quote before a ; or :, but skipping over escaped characters. (Only if the quoting or escaping is invalid will it confuse the regex.)
  • The only param-values for which we care are organiser names (ORGANIZER;CN="Doe, Jane":mailto:[email protected]) as other param-values will never need to contain any special characters.
  • Generators for comparison:
    • The npmjs module ical-generator will produce the given five escapes in text values and also \" in param-values (which it will then also quote).
    • The npmjs modules ics and node-ical-toolkit will produce the given five escapes in text values and will only escape \" in param-values, relying on quoting for the other special characters.
    • The npmjs module cozy-ical will perform the specific five escapes or unescapes in text values. I wasn't able to tell whether it escaped or quoted param-values.
    • I found an old patch for Drupal that tries to escape "s but gets it wrong, because it escapes them before it escapes \s. Well, at least it doesn't escape them as DQUOTE any more...
    • I found a Stack Overflow question where the user wanted to decode a param-value that included an escaped comma. I don't know where they got that data from originally though.
  • Parsers for comparison:
    • The npmjs module node-ical will perform the specific five unescapes in text values only.
    • In text values, libical additionally decodes \b, \t, \f and \r as if they were C characters and also unescapes \", but replaces any other unsupported escapes with spaces. (Old versions of libical used to generate those escapes, but new versions just insert literal tabs as required by the RFC.) It does not attempt to escape or unescape param-values, but will quote and unquote them.

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.

2 participants