-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
TC-6.0.37
-
None
-
5
-
Severity 3 - Minor
-
1
-
Summary
Importing a calendar that contains an URL field with encoded special characters fails with a NullPointerException.
Steps to Reproduce
- Export a calendar on a different application (.ics format)
- The source calendar must contain links starting with special characters on a new line in event descriptions
- Try to import the calendar
Expected Results
The calendar is imported.
Actual Results
The import fails and we see the message "The uploaded data does not seem to be iCalendar content" on the UI:
The follow exception is thrown in the atlassian-confluence.log file after enabling DEBUG mode for the class com.atlassian.confluence.extra.calendar3:
2019-07-16 14:30:21,457 DEBUG [http-nio-8090-exec-5] [extra.calendar3.xwork.ImportSubCalendarAction] validate Unable to read uploaded file as iCalendar -- referer: http://localhost:8090/calendar/mycalendar.action | url: /plugins/calendar/importsubcalendar.action | traceId: 852fdf13c1165f81 | userName: admin | action: importsubcalendar net.fortuna.ical4j.data.ParserException: Error at line 174:null at net.fortuna.ical4j.data.CalendarParserImpl.parse(CalendarParserImpl.java:188) at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:251) at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:232) at net.fortuna.ical4j.data.CalendarBuilder.build(CalendarBuilder.java:220) at com.atlassian.confluence.extra.calendar3.xwork.ImportSubCalendarAction.validate(ImportSubCalendarAction.java:162) Caused by: java.lang.NullPointerException at com.atlassian.confluence.extra.calendar3.ical4j.DefaultPropertyFactory$UrlFactory$LightweightUrl.setUri(DefaultPropertyFactory.java:91) at com.atlassian.confluence.extra.calendar3.ical4j.DefaultPropertyFactory$UrlFactory$LightweightUrl.setValue(DefaultPropertyFactory.java:86) at net.fortuna.ical4j.data.CalendarBuilder$ContentHandlerImpl.propertyValue(CalendarBuilder.java:384) at com.atlassian.confluence.extra.calendar3.ical4j.ContentHandlerDecorator.propertyValue(ContentHandlerDecorator.java:59) at net.fortuna.ical4j.data.CalendarParserImpl$PropertyParser.parse ...
Notes
As mentioned in the log, the offending line is 174, If we inspect the sample-cal.ics attached, we can see that it contains the following URL:
URL;VALUE=URI:%3Chttp://link%3E
The %3C combination is the ASCII encoding for the "<" tag. This means that the original calendar had the following link in its description:
<http://link>
So far, we identified only one situation where links like this are encoded by the export tool and cause the problem:
- Link starting with a "<" tag at the start of a new line
Although this is an unexpected situation and the encoding is performed by the source calendar tool during the export, Team Calendars should handle it more gracefully. Instead of halting the import, it should continue it but log an error about the invalid URL field.
Workaround
To identify the offending event, proceed as follows:
- Visit Logging and Profiling
- Add the following class:
com.atlassian.confluence.extra.calendar3
- Set the log level to DEBUG
- Click Save at the bottom of the page
- Try to import the calendar again
- Check the atlassian-confluence log
- The error message will point the offending line as follows:
net.fortuna.ical4j.data.ParserException: Error at line <LINE-NUMBER>:null
- Once that is identified, edit the ics file and remove the encoded tags so the link looks like this:
URL;VALUE=URI:http://link
- Save the file and try to import it again.