PUBLIC - Liferay Portal Community Edition

Calendar exports HTML tags

Details

  • Similar Issues:
    Show 5 results 
  • Business Value:
    2

Description

CalEventLocalServiceImpl.toICalVEvent() simply adds the description to the resulting iCal4j VEvent by calling new Description(event.getDescription()).

This leads to HTML markup embedded in the calendar export since the implementation of LPS-7966.

HTML markup needs to be removed from the description suring export or replaced with newlines/tabs in some cases.

The following code snippet could be an indication on what could be possibly done:

String descriptionStr = event.getDescription();
		
descriptionStr = StringUtil.trim(description);
descriptionStr = description.replaceAll("\r|\n|\t", StringPool.BLANK);
descriptionStr = description.replaceAll("(?i) ", StringPool.SPACE);
descriptionStr = description.replaceAll("(?i)<li>", "\n* ");
descriptionStr = description.replaceAll("(?i)<dd>", "\n\t");
descriptionStr = description.replaceAll("(?i)<td>", "\t");
descriptionStr = description.replaceAll("(?i)<a.+href=\"(.+)\"(?:/>|>.*</a>)", "$1");
descriptionStr = description.replaceAll("(?i)</?(?:br|p|div|h.|dt|tr)/?>(?!$)", StringPool.NEW_LINE);
descriptionStr = HtmlUtil.unescape(description);
descriptionStr = HtmlUtil.stripHtml(description);
descriptionStr = description.replaceAll("(?:\\n\\s*)+", StringPool.NEW_LINE);

Description description = new Description(descriptionStr);

In addition the HTML version of the description could be added in the X-ALT-DESC property to allow calendars like Outlook to still show the full HTML.

final XProperty altDesc = new XProperty("X-ALT-DESC", event.getDescription());
altDesc.getParameters().add(new XParameter("FMTTYPE", "text/html"));
eventProps.add(altDesc);

We have performed a short test in Outlook 2007 with this snippet.

Activity

Hide
Soeren Unruh added a comment -

Maybe CalEventLocalServiceImpl.importICal4j() should also do some replacing of newlines in imported events' descriptions with BR tags.

Show
Soeren Unruh added a comment - Maybe CalEventLocalServiceImpl.importICal4j() should also do some replacing of newlines in imported events' descriptions with BR tags.
Hide
Drew Blessing added a comment -

Soeren,

Thank you for your report. As part of the community verifier program I am taking a look at this issue.

Show
Drew Blessing added a comment - Soeren, Thank you for your report. As part of the community verifier program I am taking a look at this issue.
Hide
Drew Blessing added a comment -

I was able to reproduce this in Liferay 6.1 GA1.

Steps:
1. Create a calendar event with rich text.
2. Export the calendar event and download the .ics file.
3. Import .ics into a calendar program such as iCal.

Observe the HTML tags in the description of the event.

Show
Drew Blessing added a comment - I was able to reproduce this in Liferay 6.1 GA1. Steps: 1. Create a calendar event with rich text. 2. Export the calendar event and download the .ics file. 3. Import .ics into a calendar program such as iCal. Observe the HTML tags in the description of the event.
Hide
Michael Saechang added a comment -

Updated ticket as per Drew's comment. Thank you for verifying.

Show
Michael Saechang added a comment - Updated ticket as per Drew's comment. Thank you for verifying.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: