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

parseICS fails if timezone id is a number #311

Closed
antislash21 opened this issue Mar 1, 2024 · 0 comments
Closed

parseICS fails if timezone id is a number #311

antislash21 opened this issue Mar 1, 2024 · 0 comments

Comments

@antislash21
Copy link

I try to import an ics file (Thunderbird calendar export) with sync.parseICS function and get the following error:

Mon agenda.txt

TypeError: dt.tz.replace is not a function
addTZ /node_modules/node-ical/ical.js:105
dateParameter /node_modules/node-ical/ical.js:300
DTSTART /node_modules/node-ical/ical.js:650
handleObject /node_modules/node-ical/ical.js:674
parseLines /node_modules/node-ical/ical.js:726
parseICS /node_modules/node-ical/ical.js:762
parseICS /node_modules/node-ical/node-ical.js:206
onload /imports/ui/components/system/Calendar/utils.js:218
utils.js:147:14

after adding some console.log in ical.js, it seems that the problem comes from the fact that i have "TZID: 1", which makes the timezone id interpreted as a number.

The following code fails in ical.js (line 94 in function addTZ) :

    if (dt.tz !== undefined) {
      // Remove surrounding quotes if found at the beginning and at the end of the string
      // (Occurs when parsing Microsoft Exchange events containing TZID with Windows standard format instead IANA)
      dt.tz = dt.tz.replace(/^"(.*)"$/, '$1');
    }

If i change it to the following, parsing the file succeeds :

    if (dt.tz !== undefined && typeof(dt.tz) === "string") {
      // Remove surrounding quotes if found at the beginning and at the end of the string
      // (Occurs when parsing Microsoft Exchange events containing TZID with Windows standard format instead IANA)
      dt.tz = dt.tz.replace(/^"(.*)"$/, '$1');
    }

Thanks for your time,
regards

sujal pushed a commit to Metacrafters/node-ical that referenced this issue May 7, 2024
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

No branches or pull requests

1 participant