-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix availability free-busy data pull, location change and status in CALDAV | new branch (attempt#2) #3958
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Self review
@@ -251,9 +251,13 @@ export default abstract class BaseCalendarService implements Calendar { | |||
objects.forEach((object) => { | |||
if (object.data == null) return; | |||
|
|||
const jcalData = ICAL.parse(object.data); | |||
const jcalData = ICAL.parse(sanitizeCalendarObject(object)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on the CalDAV service provider, the object.data
may or may not have \r
or \r\n
as the EOL. ICAL.parse
expects it to have '\r\n' to work as expected. Also, the object.data
received from the fetchCalendarObjects
function is at times faulty in placing the EOL, which is why we need to make sure that it doesn't break the structure of expected input for ICAL.parse
, hence the need for sanitization.
const vcalendar = new ICAL.Component(jcalData); | ||
const vevent = vcalendar.getFirstSubcomponent("vevent"); | ||
|
||
// if event status is free or transparent, return | ||
if (vevent?.getFirstPropertyValue("transp") === "TRANSPARENT") return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If an event is added as a Free event, meaning we should allow booking over it, this is how we identify the free state and ignore any further processing
.replaceAll("\r\n", "\r") | ||
.replaceAll("\r", "\r\n") | ||
.replaceAll(/(: \r\n|:\r\n|\r\n:|\r\n :)/gm, ":") | ||
.replaceAll(/(; \r\n|;\r\n|\r\n;|\r\n ;)/gm, ";") | ||
.replaceAll(/(= \r\n|=\r\n|\r\n=|\r\n =)/gm, "="); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We make sure the ICAL.parse
works with the output of this return. Currently, this seems to be fixing all potential invalid breakpoints but this can be revisited and improved if there are other edge cases we might have missed here.
.replaceAll("\r\n", "\r") | ||
.replaceAll("\r", "\r\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we're going from \r\n
to \r
and then back from \r
to \r\n
here is because some of the CalDAV services return the EOL as \r
while others as \r\n
and the ICAL.parse
expects it to have \r\n
as EOL, so this just ensures all the returned Calendar objects have \r\n
as EOL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nitpick replaceAll
is not supported on browsers. And it is generally deprecated.
What does this PR do?
ICALstring
returned in the calendar objects by TSDAV'sfetchCalendarObjects
and the expected input fromICAL.parse()
Fixes #3589 #2988 #2236 #1588
Environment: Staging(main branch)
Type of change