Foros de discusión

Ampersand in page name + Liferay 5.2.3 + Glassfish2

thumbnail
Zsolt Balogh, modificado hace 14 años.

Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
Hi,

I'm investigating a problem which was originally found in webspace:

If you put a & sign(ampersand) into the name of a page, it will be reduced to the size limited before the &

So if you set Q&A as the page name, it will be only Q.

This problem should be a Glassfish issue, as it works perfectly in Liferay + Tomcat + HSQL and Liferay + Tomcat + Postgresql, Liferay + Tomcat + Mysql

Hard to search the web for this issue, I've found some ideas, but none of them worked yet.
thumbnail
Zsolt Balogh, modificado hace 14 años.

RE: Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
In DB it seems to be ok:
<!--?xml version="1.0" ?-->
<root available-locales="en_US" default-locale="en_US">
<name language-id="en_US">[b]Q&amp;A[/b]</name>
</root>
thumbnail
Zsolt Balogh, modificado hace 14 años.

RE: Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
I've found the cause of this error:

while Liferay writes Q&amp;A into the database, it should write ![CDATA[Q&A]]>

We can switch on CDATA in the LocalizationUtil, but it will return Q&amp;A then, so it's not the solution.

The code:

package test;

import java.io.StringReader;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String xml = "<!--?xml version=\"1.0\" ?--><test>Q&amp;A</test>";
		XMLStreamReader reader = null;
		XMLInputFactory factory = XMLInputFactory.newInstance();

		try {
			reader = factory.createXMLStreamReader(new StringReader(xml));
			reader.next();
			reader.next();
			System.out.println(reader.getText());
		} catch (XMLStreamException e) {
			e.printStackTrace();
		}

	}

}


returns Q only, I'm really curios now what's the difference with Tomcat...
thumbnail
Zsolt Balogh, modificado hace 14 años.

RE: Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
Ok, I've found the difference: the wstx.jar

Tomcat will work as "bad" as glassfish without it. emoticon

So we are just have to decide which is the good solution, jdk's one (then this is a liferay bug), or the wstx one (then it's a jdk bug).

Nice one, it seems to be a jdk bug: <company_name>AT&amp;T</company_name> (Sorce: Wikipedia)


The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively.

Source: w3.org
thumbnail
Zsolt Balogh, modificado hace 14 años.

RE: Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
And the issue is here: LPS-4266

Sorry for posting too much.
thumbnail
Zsolt Balogh, modificado hace 14 años.

RE: Ampersand in page name + Liferay 5.2.3 + Glassfish2

Expert Mensajes: 463 Fecha de incorporación: 23/03/09 Mensajes recientes
I've got a solution for this issue: set glassfish to use woodstox instead of the default parser.

Help for the configuration: http://weblogs.java.net/blog/bhaktimehta/archive/2007/06/woodstox_in_gla_1.html