When you write your blog entry, you usually don’t think about things like colons (:). It turns out that Liferay at least as of 6.0 SP1 has issues with colons in blog entry titles, which is especially noticeable in the RSS feeds. How to fix these? Thanks to Open Source, you can fix them yourself pretty easily.

This fix requires an EXT environment as you will be overriding 2 core Liferay classes to get the behavior necessary to support characters such as colons. To do so, start with the Liferay SDK and create an EXT plugin, if you’re working with 6.0 EE. Copy these two classes from the Liferay source into the appropriate directory structure in the ext-impl directory of the EXT plugin (sdk/ext/xtivia-ext/docroot/WEB-INF/ext-impl/src).

  • RSSAction.java
  • BlogsEntryServiceImpl.java

Both of these files will require the same alteration: the blog entry title needs to be URL encoded. To do so, add the following two lines to the imports:

	import java.io.UnsupportedEncodingException;
        import java.net.URLEncoder;

and replace the following block of code:

	if (entryURL.endsWith("/blogs/rss")) {
	    link.append(entryURL.substring(0, entryURL.length() - 3));
	    link.append(entry.getUrlTitle());
	}

with

	if (entryURL.endsWith("/blogs/rss")) {
	    link.append(entryURL.substring(0, entryURL.length() - 3));
	    try {
	        link.append(URLEncoder.encode(entry.getUrlTitle(), "UTF-8"));
	    } catch (UnsupportedEncodingException e) {
	        e.printStackTrace();
	    }
	}

Build and deploy the ext plugin, restart your application server, and you should be able to utilize colons and other URL encoded characters in your title.

Notes:

You can only deploy one EXT plugin per environment. EXT plugins usually complicate the upgrade process as they will be one more potential point of contention. While these changes are minor, they will most likely require that the above process will have to be applied to the files from the new version.

Share This