Bug 14590 - fmt:message + fmt:param tag chokes when the value contains single quotes
Summary: fmt:message + fmt:param tag chokes when the value contains single quotes
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2002-11-15 13:44 UTC by peter lin
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description peter lin 2002-11-15 13:44:19 UTC
A coworker discovered a bug with <fmt:message> that use <fmt:param> parameters. 
Here is a description of how to produce the bug.

make a properties file named test.properties in

param.key=text before ftm' param {0} text after ftp param

In the JSP, use fmt tag to get the corresponding values out.

<fmt:setBundle basename="test.test" var="test" scope="request"/>

<fmt:message key="param.key" bundle="${test}">
  <fmt:param><c:out value="speedy gonzales"/></fmt:param>

what ends up happening is the "'" causes it to not display correctly. 
If you change "fmt'" to just "fmt", the message will display correctly. Also, if 
you use two single quotes instead of one, the message will display correctly. 
When <fmt:message> is used without <fmt:param>, single quotes do not cause a bug 
and display correctly.

peter lin
Comment 1 Pierre Delisle 2002-11-22 22:34:47 UTC
This is not a bug in JSTL, but a peculiarity of how a single
quote is interpreted by java.text.MessageFormat.

For more details, you may want to check bug
reports 4293229 and 4321513 in the java bug database

The simple rule is as follows:
If there is a {0} placeholder in a message string, 
single quotes have to be doubled.

    -- Pierre