Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: 6.1.0 CE GA1
-
Fix Version/s: None
-
Component/s: Calendar
-
Labels:
-
Fix Priority:2
-
Similar Issues:
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.

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