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

Make parser more lenient for date-time values (invalid date-time value: "2015-08-12T::") #186

Closed
bliet opened this issue Aug 13, 2015 · 6 comments · Fixed by #412
Closed

Comments

@bliet
Copy link

bliet commented Aug 13, 2015

I get the Error
Uncaught Error: invalid date-time value: "2015-08-12T::"

error

in line

if(iCalEvent.startDate)

the ical file:

BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:45574333
SUMMARY:ERANOS-Ensemble für Alte Musik - Arbeitswoche
DESCRIPTION:Ltg.: Prof. Frank Löhr Anmeldung für interessierte Zuhörer unter: info@musikfreunde.org 

(Veranstalter: Gesellschaft der Musikfreunde Marienmünster)
LOCATION:Marienmünster
CLASS:PUBLIC
DTSTART:20150812
DTEND:20150814
DTSTAMP:20150813T131400Z
END:VEVENT
END:VCALENDAR

Outlook read this file as an all day event from 12.08.2015 to 14.08.2015.

@kewisch
Copy link
Owner

kewisch commented Aug 19, 2015

The parser is pretty strict about values, I haven't yet looked into a good way to control how strict it should be. The problem is that the DTSTART and DTEND in your ics data uses the default value type (DATE-TIME), since it does not have a VALUE parameter. The actual value is a DATE value, therefore ical.js breaks with this not-so-obvious error message. The correct ics would use DTSTART;VALUE=DATE:20150812 and DTEND;VALUE=DATE:20150814.

@bliet
Copy link
Author

bliet commented Aug 20, 2015

It would be nice, if the parser could be more flexible.
In this case it is true, that VALUE=DATE is missing, but on the other hand it is clear that it is a date, isn't it?

@kewisch kewisch changed the title Uncaught Error: invalid date-time value: "2015-08-12T::" Make parser more lenient for date-time values (invalid date-time value: "2015-08-12T::") Sep 17, 2015
@fbacker
Copy link

fbacker commented Apr 5, 2016

change in ical.js line 5587

if (aValue.length < 19) {
    if(aValue.length == 13){ // No time "2017-01-01T::"
        var time = new ICAL.Time({
            year: ICAL.helpers.strictParseInt(aValue.substr(0, 4)),
            month: ICAL.helpers.strictParseInt(aValue.substr(5, 2)),
            day: ICAL.helpers.strictParseInt(aValue.substr(8, 2)),
            hour: 0,
            minute: 0,
            second: 0,
            timezone: "Z"
        });
        return time;
    }
  throw new Error(
    'invalid date-time value: "' + aValue + '"'
  );
}

@papandreou
Copy link

I just ran into the same. Ended up doing a traversal of the jCal before instantiating components:

function fixUpJcal(jCal) {
    jCal[1].forEach(function (property) {
        if (property[0] === 'dtstart' || property[0] === 'dtend' || property[0] === 'exdate' || property[0] === 'rdate') {
            if (!property[1].value && property[2] === 'date-time' && /T::$/.test(property[3])) {
                property[2] = 'date';
                property[3] = property[3].replace(/T::$/, '');
            }
        }
    });
    jCal[2].forEach(fixUpJcal);
    return jCal;
}

@bengotow
Copy link

bengotow commented Oct 23, 2019

Hey folks! Just wanted to chime in that this is still a bug and we've been running in to it a lot in the Mailspring calendar app. I will see if I can submit a PR for this.

image

EDIT: It looks like there's already a PR for this above but it's unlikely to be merged.

@kewisch
Copy link
Owner

kewisch commented Oct 23, 2019

I'm working on a new patch that will make DATE, DATE-TIME, and PERIOD values more lenient when setting a specific flag for the parser. I'm pretty far through, just need to do some clean up, make sure I'm happy with the level of leniency, and check if there are other properties that might need similar treatment.

bengotow added a commit to Foundry376/Mailspring that referenced this issue Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants