Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-58592

Calendar fails to import if it contains URLs with encoded special characters

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • TC-6.0.37
    • Apps - Team Calendar
    • None

    Description

      Summary

      Importing a calendar that contains an URL field with encoded special characters fails with a NullPointerException.

      Steps to Reproduce

      1. Export a calendar on a different application (.ics format)
      2. The source calendar must contain links starting with special characters on a new line in event descriptions
      3. 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:

      1. Visit Logging and Profiling
      2. Add the following class:
        com.atlassian.confluence.extra.calendar3
        
      3. Set the log level to DEBUG
      4. Click Save at the bottom of the page
      5. Try to import the calendar again
      6. Check the atlassian-confluence log
      7. The error message will point the offending line as follows:
        net.fortuna.ical4j.data.ParserException: Error at line <LINE-NUMBER>:null
        
      8. Once that is identified, edit the ics file and remove the encoded tags so the link looks like this:
        URL;VALUE=URI:http://link
        
      9. Save the file and try to import it again.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bandreeti Bernardo Andreeti
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: